-
Notifications
You must be signed in to change notification settings - Fork 18k
SIGCHLD wakes up time.Sleep #268
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
Labels
Comments
The problem is that when the forked /bin/date exits, Sleep gets a signal and doesn't restart. It's hard to know what to do here in general--this is really a question of Unix semantics, not Go semantics-- but I think the solution is to not allow SIGCHLD to interrupt system calls. Owner changed to r...@golang.org. Status changed to Accepted. |
Confirmed. This functions as expected: --- Example --- package main import "fmt" import "os" import "time" import "syscall" func main() { var wstatus syscall.WaitStatus; fmt.Printf("First 5 sec Sleep\n" ) ; time.Sleep(1000* 1000*1000 * 5) ; // wait must be called on the forked proc, otherwise the SIGCHILD interferes with the subsequent call to time.Sleep pid, forkerr := os.ForkExec("/bin/date", []string{"date"}, os.Environ(), "", []*os.File{os.Stdin, os.Stdout, os.Stderr}); _, waiterr := syscall.Wait4(pid, &wstatus, 0, nil); fmt.Printf( "pid, forkerr, waiterr:%d, %d, %d\n" , pid, forkerr, waiterr ) ; fmt.Printf("Second 5 sec Sleep\n" ) ; time.Sleep(1000* 1000*1000 * 5) ; fmt.Printf("Done\n" ) ; } --- /Example --- Probably should be using the exec.Cmd struct for this type of functionality. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by gfranxman:
The text was updated successfully, but these errors were encountered: