Skip to content
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

'time.Sleep(); blocks child after fork if 'rand.Reader.Read()' is used before #6664

Closed
gopherbot opened this issue Oct 25, 2013 · 4 comments
Closed

Comments

@gopherbot
Copy link

by mihael.dimec:

What steps will reproduce the problem?
 Compile and run example.

What is the expected output?
miha@miha-work:~/testi/go_sleep $ ./go_sleep
strength =  3 cnt =  3
Parent before sleep
[6 15 113]
Child before sleep
[6 15 113]
Parent after sleep
Child after sleep

What do you see instead?
miha@miha-work:~/testi/go_sleep $ ./go_sleep
strength =  3 cnt =  3
Parent before sleep
[6 15 113]
Child before sleep
[6 15 113]
Parent after sleep


Which compiler are you using (5g, 6g, 8g, gccgo)?
go build

Which operating system are you using?
Ubuntu 12.10
Linux miha-work 3.5.0-32-generic #53-Ubuntu SMP Wed May 29 20:23:04 UTC 2013 x86_64
x86_64 x86_64 GNU/Linux


Which version are you using?  (run 'go version')
go version go1.1.2 linux/amd64

Forked child will block at 'time.Sleep(time.Milliecond)' function call, if
'rand.Reader.Read(k)' before fork.

Attachments:

  1. main.go (915 bytes)
@cznic
Copy link
Contributor

cznic commented Oct 25, 2013

Comment 1:

Go programs do not support forking.

@gopherbot
Copy link
Author

Comment 2 by mihael.dimec:

Thank you for response.
I don't understand two things.
1.) Why am I able to fork if I'm not suppose to?
2.) Fork is basic and common system call. Why fork is not supported?

@cznic
Copy link
Contributor

cznic commented Oct 25, 2013

Comment 3:

1. Using syscalls is always on your own responsibility.
2. See eg. https://groups.google.com/d/msg/golang-nuts/KynZO5BQGks/nlTgevsrJJUJ

@ianlancetaylor
Copy link
Contributor

Comment 4:

There is no reasonable way for a threaded program to call fork, and Go programs are
always threaded.
You didn't say why you want to call fork, but you may want to look at issue #227.

Status changed to Unfortunate.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants