Fork: Difference between revisions

Content added Content deleted
(Scala added)
(→‎{{header|Go}}: mention ForkExec; add godoc link)
Line 370:
 
=={{header|Go}}==
This program prints its own pid, then runs a copy of itself if given any argument on the command line. When it does so, it prints the pid of the child process it started. Output should show this pid matching the child's self reported pid. See also package os/exec which offers a higher level interface and may be simpler in some situations. For the purpose of this task though, there is little difference.
Note that on Unix like systems <code>os.StartProcess</code> is a wrapper around <code>syscal.ForkExec</code> (which as the name implies, safely calls <code>fork</code> and <code>exec</code> system calls).
The [https://golang.org/pkg/os/exec <code>os/exec</code>] package offers a higher level interface and may be simpler in some situations.
For the purpose of this task though, there is little difference.
<lang go>package main