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

runtime: Go function call is hanging forever in C child process. #14767

Closed
wickedev opened this issue Mar 11, 2016 · 1 comment
Closed

runtime: Go function call is hanging forever in C child process. #14767

wickedev opened this issue Mar 11, 2016 · 1 comment

Comments

@wickedev
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

go version go1.6 linux/amd64

gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4

  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ams2/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

my example program

  1. What did you expect to see?

I wanna call Go function in C child process

  1. What did you see instead?

I'd like to call Go function from C program as like a static library. and I was trying to make my C daemon program using fork(). but as you see in my _main.c code(in my reop), Go function call hanging forever in child process.

Thank you in advance for your help.

@wickedev wickedev changed the title Go function call is hanging forever in C child process. runtime: Go function call is hanging forever in C child process. Mar 11, 2016
@ianlancetaylor
Copy link
Contributor

In general fork does not work with multi-threaded processes, and Go programs are always multi-threaded. A simple fork/exec that does not call any Go code between fork and exec should work. An attempt to call Go code after fork will generally fail, as you are seeing.

There is really no way to fix this, so I am going to close this issue. If you want to discuss this, please use a forum, not the issue tracker; see https://golang.org/wiki/Questions.

@golang golang locked and limited conversation to collaborators Mar 13, 2017
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