I made program in Go that kills a process with syscall.Kill()
But if I daeminze that process with fork()
+ setsid()
then syscall.Kill()
does not kill that process.
If I use shell kill
then I'm able to kill that process in both cases.
I tried different signals: SIGINT
, SIGTERM
and SIGKILL
buthey do not kill the daemon.
run.pid
file andPID
is printed on screen. SoPID
is correct. – Canadasyscall.Kill
returnsnil
– Canadasyscall.Kill()
is working, and then adding fork() makes it stop working, then it sounds plausible that you're killing the initial process, and not the child one. Did you collate PID not only with run.pid, but also the output of ps aux? – Hamlettsyscall.Getpid()
after fork. I print PID that I pass tosyscall.Kill()
. It seems I am unable to start web server in daemon also. I even tried to use unix sockets. It creates socket file but control is not working. But daemon is able to run subprocess that is able to start webserver. Is there something related to permissions that block daemonized process from listening. If I do not daemonize process then everyting works. (Signals, WebServers, Unix Sockets) It is very odd that I can't kill that process. It looks like it is dead and not working. – Canadanohup
right now. I used code inspired with gist.github.com/wofeiwo/3634357 – Canada