You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
runtime/cgo:deadlock during daemons in _cgo_wait_runtime_init_done
runtime/cgo: deadlock during daemons in _cgo_wait_runtime_init_done
May 6, 2019
I don't think there is any safe way to daemonize a program once the Go runtime has started, since the daemonization process copies only one thread, not all existing ones. When there are other threads running during daemonization, the daemonized process is starting with inconsistent memory. That is most likely the cause of the problem you are seeing. See the discussion in #227.
The only reasonable fix I know of is to make sure the daemonization happens before the Go runtime starts, either by doing it in a separate program or by doing it as a high priority initializer.
The simplest way is to use a separate program. It should do what your init_daemon function does, except that after the second fork it should execve the program you want to run as a daemon.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I am developing a static library with GO for use in C/C++
Here is an example:
The go code:
Compile the static library and use it
What did you expect to see?
Hello World From Go!
What did you see instead?
The cgo blocked!
What do I need to do?
The text was updated successfully, but these errors were encountered: