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