The mi_process_exec() function
The mi_process_exec() function forks and executes a new process, returning before this new process completes.
Syntax
mi_integer mi_process_exec(argv)
char *argv[];
- argv
- A pointer to the command array, which provides the commands to execute in the newly forked process.
Valid in client LIBMI application? | Valid in user-defined routine? |
---|---|
No | Yes |
Usage
- The first element must be an executable program or script.
You must provide the full path name of this program or script. A single environment variable is allowed as a prefix using the same rules as the mi_file_open() function.
To include environment variables in the command path name, use the following syntax:$ENV_VAR
To use the PATH environment variable, you must execute the command through a shell (such as /bin/sh). However, make sure that the command is also executable:/bin/sh -c cmd
If the command is a script, it must be executable and start with a shell identifier (such as “#!/bin/sh”).
- The last element must be the keyword NULL.
char *argv[5];
argv[0] = "/usr/ucb/touch";
argv[1] = "somefile";
argv[2] = NULL;
mi_process_exec(argv);
argv[0] = "/bin/sh";
argv[1] = "-c";
argv[2] = "touch";
argv[3] = "somefile";
argv[4] = NULL;
mi_process_exec(argv);
$ONEDB_HOME/bin
This function is useful if you need to perform a UNIX or Linux™ fork() and exec() from a C UDR.
Return values
- MI_OK
- The function was successful.
- MI_ERROR
- The function was not successful.
The mi_process_exec() return value is not a success indicator for the executed process. No feedback occurs between the C-function call and the actual fork() and exec() tasks, which takes place in the ADM VP at some time in the near future when the child-status timer goes off.