Skip to content

Commit

Permalink
Fix race condition for rewriting content of the buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Sep 11, 2024
1 parent 076c89c commit 7cc4621
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/envd/internal/services/process/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ func New(user *user.User, req *rpc.StartRequest, logger *zerolog.Logger, envVars

for {
n, readErr := tty.Read(buf)
chunk := make([]byte, n)
copy(chunk, buf[:n])

if n > 0 {
outMultiplex.Source <- rpc.ProcessEvent_Data{
Data: &rpc.ProcessEvent_DataEvent{
Output: &rpc.ProcessEvent_DataEvent_Pty{
Pty: buf[:n],
Pty: chunk,
},
},
}
Expand Down

0 comments on commit 7cc4621

Please sign in to comment.