Skip to content

Commit

Permalink
add diff channels back
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Huckins <dhuckins@users.noreply.github.com>
  • Loading branch information
dhuckins committed May 23, 2023
1 parent 373a57e commit 7258c14
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions command/agent/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Server struct {
childProcessState childProcessState

// exit channel of the child process
childProcessExitCh <-chan int
childProcessExitCh chan int
}

type ProcessExitError struct {
Expand All @@ -76,9 +76,10 @@ func (e *ProcessExitError) Error() string {

func NewServer(cfg *ServerConfig) *Server {
server := Server{
logger: cfg.Logger,
config: cfg,
childProcessState: childProcessStateNotStarted,
logger: cfg.Logger,
config: cfg,
childProcessState: childProcessStateNotStarted,
childProcessExitCh: make(chan int),
}

return &server
Expand Down Expand Up @@ -247,7 +248,15 @@ func (s *Server) bounceCmd(newEnvVars []string) error {
return err
}
s.childProcess = proc
s.childProcessExitCh = s.childProcess.ExitCh()
// did not work
// s.childProcessExitCh = s.childProcess.ExitCh()
go func() {
select {
case exitCode := <-proc.ExitCh():
s.childProcessExitCh <- exitCode
return
}
}()

if err := s.childProcess.Start(); err != nil {
return fmt.Errorf("error starting child process: %w", err)
Expand Down

0 comments on commit 7258c14

Please sign in to comment.