# Command: fork

NEST HelpDesk | Command Index | NEST Quick Reference

Name:

    fork - create a child process of SLI

Synopsis:

    fork -> PID

Examples:

    1. fork
      (Well, just kidding...)

      2. fork 0 eq {(I'm the child!) = quit} {(I'm the parent!) =} ifelse
      Try this several times. You will notice the child message to appear
      before or after the parent message "by chance". (Even after the
      parent's SLI-prompt...)

Description:

    Thin wrapper to the fork() system function

Parameters:

    In : -none-
      Out: PID(integer) : 0 (for the child)
      the child's process ID (for the parent)

Bugs:

    -

Remarks:

    A full parallel process of SLI is forked.
      Parent and child will execute in parallel. There is no way to know
      which will start being executed first.
      Child inherits all open files, including stdin and stdout, from parent!
      Thus, calling fork interactively from the SLI-prompt will result in
      command-line-confusion if both processes end up without quitting.
      If fork() cannot be executed, an error is raised.

      SLI-function spoon (processes.sli) is a more convenient wrapper
      to fork!

Author:

    R Kupper

FirstVersion:

    Mar 17 1999

SeeAlso:

- spoon
- sysexec
- getPID
- getPPID
- getPGRP
- wait
- waitPID

Source:

    /opt/conda/conda-bld/nest_1510212701067/work/nest-2.14.0/sli/processes.h

NEST HelpDesk | Command Index | NEST Quick Reference

© 2004 The NEST Initiative