In the child the pid
is zero
, fork
returns child pid to parent, but child gets zero
, and u r trying to kill a process with pid 0, but pid of init is 1
, u can use getpid()
to get the current pid
of the child
. and then try to signal it.
Edit:
And also, pid
is un initialized when the loop enters first time, which may also result in undefined behavior. Thanks @Giresh