Skip to main content
Tweeted twitter.com/#!/StackUnix/status/38423217764827136
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
Source Link
Cory Klein
  • 19.4k
  • 28
  • 84
  • 96

Does bash support forking similar to C's fork()?

I have a script that I would like to fork at one point so two copies of the same script are running.

For example, I would like the following bash script to exist:

echo $$ do_fork() echo $$ 

If this bash script truly existed, the expected output would be:

<ProcessA PID> <ProcessB PID> <ProcessA PID> 

or

<ProcessA PID> <ProcessA PID> <ProcessB PID> 

Is there something that I can put in place of "do_fork()" to get this kind of output, or to cause the bash script to do a C-like fork?