fork400() and f_fork400()--Create a New Process with IBM PASE for i Options



  Syntax
 #include <as400_protos.h>

 pid_t fork400(const char   *jobname,
               unsigned int  resourceID);

 pid_t f_fork400(const char   *jobname,
                 unsigned int  resourceID);


  Default Public Authority: *USE

  Library: Standard C Library (libc.a)

  Threadsafe: Yes


Note: These functions can only be used in an IBM® i PASE program. See the IBM PASE for i topic collection for more information about creating IBM PASE for i programs.

The fork400() function creates a new process. The new process (the child process) is an almost exact copy of the calling process (the parent process). fork400() is called once (by the parent process), but returns twice (once in the parent process and once in the child process). fork400() is the same as the fork() function plus it allows additional IBM PASE for i unique options to be specified.

f_fork400() function is a similarly enhanced version of the f_fork() function. When f_fork400() (or f_fork()) is used, one of the exec functions must be called in the child process immediately after it is created. f_fork400() does not call the fork handlers so the application data, mutexes and the locks are all undefined in the child process.


Parameters

jobname
(Input) Pointer to a null-terminated string in the IBM PASE for i CCSID that specifies the IBM i job name of the new process.

The job name specified must begin with an alphabetic character [A-Z] or the characters [$#@]. The remaining characters must be alphanumeric [A-Z] or [0-9] or [$#@_.]. The string should not be longer than 10 characters (not including the terminating null character). If the specified jobname is invalid, the jobname parameter value is ignored.

resourceID
(Input) A positive integer value specifying the resources affinity identifier for the new process.

Use the value of 0 to let the operating system select the resources affinity identifier value automatically.


Authorities

fork400() and f_fork400() require no authority.


Return Value

Upon successful completion, the fork400() or f_fork400() function returns a value of 0 to the child process and the process ID of the child process to the parent process. Otherwise, a value of -1 is returned to the parent process, no child process is created, and the errno global variable is set to indicate the error.


Error Conditions

At least these errno values can be returned, with other values also possible (such as IBM i-unique ILE errno EAPAR):



Usage Notes

  1. Consult the AIX® documentation for fork() and f_fork() for additional details regarding attributes of the parent process inherited by the child process and differences between fork() and f_fork().
  2. The IBM PASE for i environment specification QIBM_PASE_USE_PRESTART_JOBS=Y will be ignored when the fork400() or f_fork400() functions are used with a non-null jobname or a non-zero resourceID value.

Related Information



API introduced: V5R3

[ Back to top | IBM PASE for i APIs | APIs by category ]