fork400()and f_fork400()--Create A New Process with i5/OS PASE 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 i5/OS PASE program. See i5/OS PASE for more information about creating i5/OS PASE 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 i5/OS PASE 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 i5/OS PASE CCSID that specifies the i5/OS 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 i5/OS-unique ILE errno EAPAR):

[EAGAIN] Exceeds the limit on the total number of processes running or the system does not have the resources necessary to create another process.
[ENOMEM] Not enough space exists for this process.
[EINVAL] An invalid argument value was specified.


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 i5/OS PASE 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
Top | i5/OS PASE APIs | APIs by category