Passes a given string to the host environment to be executed by a command processor. This function is nonreentrant.
#include <stdlib.h> int system (const char *string);
The subprocess is spawned within the system call by a call to vfork. Because of this, a call to system should not be made after a call to vfork and before the corresponding call to an exec function.
For OpenVMS Version 7.0 and higher systems, if you include <stdlib.h> and compile with the _POSIX_EXIT feature-test macro set, then the system function returns the status as if it called waitpid to wait for the child. Therefore, use the WIFEXITED and WEXITSTATUS macros to retrieve the exit status in the range of 0 to 255.
You set the _POSIX_EXIT feature-test macro by using /DEFINE=_POSIX_ EXIT or #define _POSIX_EXIT at the top of your file, before any file inclusions.
nonzero value | If string is NULL, a value of 1 is returned, indicating that the system function is supported. If string is not NULL, the value is the subprocess OpenVMS return status. |
#include <stdlib.h> #include <stdio.h> main () { int status, fd; fd = creat ("system.test", 0); write (fd, "this is an example of using system", 34); close (fd); if system(NULL) { status = system ("DIR/NOHEAD/NOTRAIL/SIZE SYSTEM.TEST"); printf ("system status = %d\n", status); } else printf ("system() not supported.\n"); }