int main(USHORT argc, CHAR *argv[] ) { APIRET rc = NO_ERROR; /* Return code */ PID pidToIntr = 0; /* Interrupt this process */ if ( argc < 2 ) { printf("sendsig error: Need to pass PID of thread to interrupt.\n"); return 1; } else { pidToIntr = (PID) atoi ( argv[1] ); } /* endif */ rc = DosSendSignalException ( pidToIntr, /* Process to interrupt */ XCPT_SIGNAL_INTR ); /* Send this signal */ if (rc != NO_ERROR) { printf("DosSendSignalException error: return code = %u\n", rc); return 1; } else { printf ("DosSendSignalException complete.\n"); } /* endif */ return NO_ERROR; }
APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int signum) { #ifdef OS2 /* SIGTERM's don't work too well in OS/2 (only affects other EMX * programs). CGIs may not be, esp. REXX scripts, so use a native * call instead */ if (signum == SIGTERM) { return APR_OS2_STATUS(DosSendSignalException(proc->pid, XCPT_SIGNAL_BREAK)); } #endif /* OS2 */ if (kill(proc->pid, signum) == -1) { return errno; } return APR_SUCCESS; }
int ap_os_kill(pid_t pid, int sig) { /* SIGTERM's don't work too well in OS/2 (only affects other EMX programs). CGIs may not be, esp. REXX scripts, so use a native call instead */ int rc; if ( sig == SIGTERM ) { rc = DosSendSignalException( pid, XCPT_SIGNAL_BREAK ); if ( rc ) { errno = ESRCH; rc = -1; } } else { rc = kill(pid, sig); } return rc; }
static void ProcessConnection( void ) { char buff[MAX_TRANS]; ULONG bytes_read; unsigned long max; struct _AVAILDATA BytesAvail; ULONG PipeState; APIRET rc; RESULTCODES res; PID dummy; char *dir; for( ;; ) { DosRead( LnkHdl, buff, sizeof( buff ), &bytes_read ); if( bytes_read == 0 ) break; buff[bytes_read] = '\0'; switch( buff[0] ) { case LNK_CWD: rc = 0; dir = &buff[1]; if( isalpha( dir[0] ) && dir[1] == ':' ) { rc = DosSetDefaultDisk( toupper( dir[0] ) - ('A' - 1) ); dir += 2; } if( rc == 0 && dir[0] != '\0' ) { rc = DosSetCurrentDir( dir ); } SendStatus( rc ); break; case LNK_RUN: DosSetNPHState( RedirHdl, NP_NOWAIT | NP_READMODE_BYTE ); DosConnectNPipe( RedirHdl ); DosSetNPHState( RedirHdl, NP_WAIT | NP_READMODE_BYTE ); RunCmd( &buff[1] ); break; case LNK_QUERY: max = *(unsigned long *)&buff[1]; if( max > sizeof( buff ) ) max = sizeof( buff ); --max; rc = DosPeekNPipe(RedirHdl, buff, 0, &bytes_read, &BytesAvail, &PipeState ); if( rc == 0 && BytesAvail.cbpipe != 0 ) { DosRead( RedirHdl, &buff[1], max, &bytes_read ); buff[0] = LNK_OUTPUT; DosWrite( LnkHdl, buff, bytes_read + 1, &bytes_read ); } else { rc = DosWaitChild( DCWA_PROCESS, DCWW_NOWAIT, &res, &dummy, ProcId ); if( rc != ERROR_CHILD_NOT_COMPLETE ) { DosDisConnectNPipe( RedirHdl ); SendStatus( res.codeResult ); ProcId = 0; } else { /* let someone else run */ DosSleep( 1 ); buff[0] = LNK_NOP; DosWrite( LnkHdl, buff, 1, &bytes_read ); } } break; case LNK_CANCEL: DosSendSignalException( ProcId, XCPT_SIGNAL_INTR ); break; case LNK_ABORT: DosKillProcess( DKP_PROCESSTREE, ProcId ); break; case LNK_DONE: return; case LNK_SHUTDOWN: exit( 0 ); break; } } }