fork()
is a system call that is used for process creation. The calling process first creates a copy of itself (i.e. the child process) which may be followed by a call toexec()
.fork()
may fail and returns-1
in that case.- When calling
kill()
, first check if yourpid
is valid. If you treat-1
as a validpid
, you're going to kill all processes "for which the calling process has permission to send signals, except for process 1 (init)".
- If you see the error message
/bin/sh^M: bad interpreter
, your file has DOS line endings (CRLF) and must thus be converted to Unix line endings (LF) first.