@ -72,8 +72,10 @@ int parent(const char *tag, int parent_read) {
status = 0xAAAA ;
status = 0xAAAA ;
if ( wait ( & status ) ! = - 1 ) { // Wait for child
if ( wait ( & status ) ! = - 1 ) { // Wait for child
if ( WIFEXITED ( status ) ) {
if ( WIFEXITED ( status ) ) {
LOG ( LOG_INFO , " logwrapper " , " %s terminated by exit(%d) " , tag ,
if ( WEXITSTATUS ( status ) ! = 0 ) {
WEXITSTATUS ( status ) ) ;
LOG ( LOG_INFO , " logwrapper " , " %s terminated by exit(%d) " , tag ,
WEXITSTATUS ( status ) ) ;
}
return WEXITSTATUS ( status ) ;
return WEXITSTATUS ( status ) ;
} else if ( WIFSIGNALED ( status ) )
} else if ( WIFSIGNALED ( status ) )
LOG ( LOG_INFO , " logwrapper " , " %s terminated by signal %d " , tag ,
LOG ( LOG_INFO , " logwrapper " , " %s terminated by signal %d " , tag ,
@ -118,13 +120,14 @@ int logwrap(int argc, const char* argv[], int background)
if ( grantpt ( parent_ptty ) | | unlockpt ( parent_ptty ) | |
if ( grantpt ( parent_ptty ) | | unlockpt ( parent_ptty ) | |
( ( child_devname = ( char * ) ptsname ( parent_ptty ) ) = = 0 ) ) {
( ( child_devname = ( char * ) ptsname ( parent_ptty ) ) = = 0 ) ) {
LOG ( LOG_ERROR , " logwrapper " , " Problem with /dev/ptmx " ) ;
close ( parent_ptty ) ;
close ( parent_ptty ) ;
LOG ( LOG_ERROR , " logwrapper " , " Problem with /dev/ptmx " ) ;
return - 1 ;
return - 1 ;
}
}
pid = fork ( ) ;
pid = fork ( ) ;
if ( pid < 0 ) {
if ( pid < 0 ) {
close ( parent_ptty ) ;
LOG ( LOG_ERROR , " logwrapper " , " Failed to fork " ) ;
LOG ( LOG_ERROR , " logwrapper " , " Failed to fork " ) ;
return - errno ;
return - errno ;
} else if ( pid = = 0 ) {
} else if ( pid = = 0 ) {
@ -133,6 +136,7 @@ int logwrap(int argc, const char* argv[], int background)
*/
*/
child_ptty = open ( child_devname , O_RDWR ) ;
child_ptty = open ( child_devname , O_RDWR ) ;
if ( child_ptty < 0 ) {
if ( child_ptty < 0 ) {
close ( parent_ptty ) ;
LOG ( LOG_ERROR , " logwrapper " , " Problem with child ptty " ) ;
LOG ( LOG_ERROR , " logwrapper " , " Problem with child ptty " ) ;
return - errno ;
return - errno ;
}
}
@ -145,10 +149,8 @@ int logwrap(int argc, const char* argv[], int background)
if ( background ) {
if ( background ) {
int fd = open ( " /dev/cpuctl/bg_non_interactive/tasks " , O_WRONLY ) ;
int fd = open ( " /dev/cpuctl/bg_non_interactive/tasks " , O_WRONLY ) ;
if ( fd > = 0 ) {
if ( fd > = 0 ) {
char text [ 64 ] ;
char text [ 64 ] ;
sprintf ( text , " %d " , getpid ( ) ) ;
sprintf ( text , " %d " , getpid ( ) ) ;
if ( write ( fd , text , strlen ( text ) ) < 0 ) {
if ( write ( fd , text , strlen ( text ) ) < 0 ) {
LOG ( LOG_WARN , " logwrapper " ,
LOG ( LOG_WARN , " logwrapper " ,