spawnlp, spawnvp

Executes a new NLM

Local Servers:blocking
Remote Servers:N/A
Classification:Other
Service:Thread

Syntax

  #include <nwthread.h>  
   
  int spawnlp  (  
     int           mode,   
     const char   *path,   
     char         *arg0,   
     ...); 
  
  int spawnvp  (  
     int           mode,   
     const char   *path,   
     char        **argv); 
  

Parameters

mode
(IN) Specifies how the invoking program behaves after it is initiated.
path
(IN) Points to the name of the compiled program to be started.
arg0
(IN) Points to the first of a list of arguments to be passed to the invoked program.
argv
(IN) Points to an array of pointers to arguments to be passed to the invoked program.

Return Values

The following table lists return values and descriptions.

Value

Hex

Name

Description

0

(0x00)

ESUCCESS

Program was successfully loaded.

–1

(0xFF)

EFAILURE

The function failed.

On error, errno is set to one of the following values:

Value

Hex

Name

1

(0x01)

ENOENT

3

(0x03)

ENOEXEC

5

(0x05)

ENOMEM

6

(0x06)

EACCES

9

(0X09)

EINVAL (See note below)

16

(0x10)

EINUSE

19

(0x13)

EWRNGKND

21

(0x15)

ERESOURCE

28

(0x1C)

EIO

37

(0x25)

EALREADY

Through a Novell internal conversion process, NwErrno may also be set to one of the following values:

Value

Hex

Name

1

(0x01)

LOAD_COULD_NOT_FIND_FILE

2

(0x02)

LOAD_ERROR_READING_FILE

3

(0x03)

LOAD_NOT_NLM_FILE_FORMAT

4

(0x04)

LOAD_WRONG_NLM_FILE_VERSION

5

(0x05)

LOAD_REENTRANT_INITIALIZE_FAILURE

6

(x006)

LOAD_CAN_NOT_LOAD_MULTIPLE_COPIES

7

(0x07)

LOAD_ALREADY_IN_PROGRESS

8

(0x08)

LOAD_NOT_ENOUGH_MEMORY

9

(0x09)

LOAD_INITIALIZE_FAILURE

10

(0x0A)

LOAD_INCONSISTENT_FILE_FORMAT

11

(0x0B)

LOAD_CAN_NOT_LOAD_AT_STARTUP

12

(0x0C)

LOAD_AUTO_LOAD_MODULES_NOT_LOADED

13

(0x0D)

LOAD_UNRESOLVED_EXTERNAL

14

(0x0E)

LOAD_PUBLIC_ALREADY_DEFINED

NOTE:The errno code EINVAL indicates only that code was set to other than P_NOWAIT or P_WAIT.

IMPORTANT:P_WAIT is operative only in NLMs made with CLIB. Other NLMs indicate load completion only.

Remarks

The value of mode determines how the program is loaded and how the invoking program behaves after the it is initiated:

Mode

Description

P_NOWAIT

The invoked program is loaded into available memory and is executed. The original program executes simultaneously with the invoked program.

P_WAIT

The invoked program is loaded into available memory and is executed. The calling thread is suspended until the invoked program finishes (the NLM loads). Under NetWare 5.x and 6.x, the exit status of the invoked program is returned.

IMPORTANT:P_WAIT functionality is available only on NetWare 5.x, 6.x, and NetWare 4 systems updated to use CLib v. 4.11 libraries, the official update for NetWare v. 4.10 systems.

Arguments are passed to the child process by supplying one or more pointers to character strings as arguments in the spawn call. These character strings are concatenated with spaces inserted to separate the arguments to form one argument string for the child process. The length of this concatenated string must not exceed 128 bytes.

The arguments can be passed as a list of arguments ( spawnlp) or as a vector of pointers ( spawnvp). At least one argument, arg0 or argv [0], must be passed to the child process. By convention, this first argument is the name of the program.

If the arguments are passed as a list, there must be a NULL pointer to mark the end of the argument list.

See Also

abort, atexit, exit, _exit, getcmd, getenv, main, system

Example

spawnlp

  #include <nwthread.h>  
   
  int   completionCode:  
  completionCode = spawnlp (P_NOWAIT, "helper.NLM", NULL); 
  

spawnvp

  #include <nwthread.h>  
   
  int    completionCode;  
  char   *argv[5];  
  completionCode = spawnvp (P_NOWAIT, "helper.nlm", argv);