Skip to content

Fix go routine problem with netns #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,28 +226,27 @@ func main() {
signal.Notify(c, syscall.SIGINT)
signal.Notify(c, syscall.SIGTERM)

// Launch the command in a go routine
// Wait for the process to end
go func() {
err = execCmd(command)
if err != nil {
log.Warn("Error while running command : ", err)
for {
select {
// If we recieve a signal, we let it flow to the process
case signal := <-c:
log.Debugf("Got a %s", signal.String())
// If the process is done, we exit properly
case <-done:
log.Debugf("Process exited properly, exiting")
return
}
}
done <- struct{}{}
}()

// Wait for the process to end
FOR_LOOP:
for {
select {
// If we recieve a signal, we let it flow to the process
case signal := <-c:
log.Debugf("Got a %s", signal.String())
// If the process is done, we exit properly
case <-done:
log.Debugf("Process exited properly, exiting")
break FOR_LOOP
}
// Launch the command in a go routine
err = execCmd(command)
if err != nil {
log.Warn("Error while running command : ", err)
}
done <- struct{}{}

log.Debug("Go back to orignal namspace")

Expand Down