Update exec_shell command to return the exit code.
This commit is contained in:
parent
ee63cb41d2
commit
d4c2ffce68
31
DVDEmu.cpp
31
DVDEmu.cpp
|
@ -81,17 +81,40 @@ void verbose_printf( const char * const fmt, ... )
|
|||
}
|
||||
}
|
||||
|
||||
void exec_shell( const char * shellcmd )
|
||||
int exec_shell( const char * shellcmd )
|
||||
{
|
||||
if( fork() == 0 )
|
||||
int status = 0;
|
||||
pid_t pid;
|
||||
|
||||
if( (pid = fork()) == 0 )
|
||||
{
|
||||
/* Try to execute, return sentinal if failed */
|
||||
execl("/bin/bash","/bin/bash","-c",shellcmd,NULL);
|
||||
_exit(127);
|
||||
}
|
||||
else
|
||||
{
|
||||
int status;
|
||||
wait(&status);
|
||||
if( waitpid( pid, &status, 0 ) > 0 )
|
||||
{
|
||||
if (WIFEXITED(status) && !WEXITSTATUS(status))
|
||||
{
|
||||
/* Successfully completed */
|
||||
status = 0;
|
||||
}
|
||||
else if (WIFEXITED(status) && WEXITSTATUS(status))
|
||||
{
|
||||
/* Get exit code */
|
||||
status = WEXITSTATUS(status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Couldn't get program */
|
||||
status = 127;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void PrintHex( const char * prepend, const unsigned char * const data, int length )
|
||||
|
|
2
DVDEmu.h
2
DVDEmu.h
|
@ -11,7 +11,7 @@
|
|||
#define DVD_TYPE_TOSHIBA_SD_B100_DVD 3
|
||||
|
||||
void verbose_printf( const char * const fmt, ... );
|
||||
void exec_shell( const char * shellcmd );
|
||||
int exec_shell( const char * shellcmd );
|
||||
void PrintHex( const char * prepend, const unsigned char * const data, int length );
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue