OS/161 Reference Manual


system - run command as subprocess


Standard C Library (libc, -lc)


#include <stdlib.h>

system(const char *command);


The system routine executes command as if it were typed into the shell.

Return Values

On success, system returns the exit status returned from waitpid. On error, -1 is returned, and errno is set according to the error encountered.


Any of the errors from fork or waitpid. Errors generated during execv cannot readily be reported back in detail.


In OS/161 there may be no shell and when there is the shell's behavior and syntax is not specified. For this reason we make no assumptions about the shell's operation, and assume system cannot reliably use the shell to parse and execute command. Instead, system does this itself, in a way which may not necessarily be compatible with the shell as it finally appears. You may want to change system to invoke the shell in a suitable fashion when/if a shell is available.