1 /* system( const char * )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
9 /* This is an example implementation of system() fit for use with POSIX kernels.
12 extern int fork( void );
13 extern int execve( const char * filename, char * const argv[], char * const envp[] );
14 extern int wait( int * status );
16 int system( const char * string )
18 char const * const argv[] = { "sh", "-c", (char const * const)string, NULL };
24 execve( "/bin/sh", (char * * const)argv, NULL );
28 while( wait( NULL ) != pid );
35 #include <_PDCLIB_test.h>
37 #define SHELLCOMMAND "echo 'SUCCESS testing system()'"
41 TESTCASE( system( SHELLCOMMAND ) );