system

OS/161 Reference Manual

Name

system - run command as subprocess

Library

Standard C Library (libc, -lc)

Synopsis

#include <stdlib.h>

int
system(const char *command);

Description

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.

Errors

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

Restrictions

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. 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.