1 /* $Header: /home/cvs/wavplay/procterm.c,v 1.1.1.1 1999/11/21 19:50:56 wwg Exp $
2 * Warren W. Gay VE3WWG Wed Feb 26 22:43:33 1997
3 *
4 * INTERPRET PROCESS TERMINATION:
5 *
6 * X LessTif WAV Play :
7 *
8 * Copyright (C) 1997 Warren W. Gay VE3WWG
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation version 2 of the License.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details (see enclosed file COPYING).
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 * Send correspondance to:
24 *
25 * Warren W. Gay VE3WWG
26 *
27 * Email:
28 * ve3wwg@yahoo.com
29 * wgay@mackenziefinancial.com
30 *
31 * $Log: procterm.c,v $
32 * Revision 1.1.1.1 1999/11/21 19:50:56 wwg
33 * Import wavplay-1.3 into CVS
34 *
35 * Revision 1.1 1997/04/14 00:07:16 wwg
36 * Initial revision
37 *
38 */
39 static const char rcsid[] = "@(#)procterm.c $Revision: 1.1.1.1 $";
40
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <unistd.h>
44 #include <signal.h>
45 #include <string.h>
46 #include <sys/types.h>
47 #include <sys/wait.h>
48
49 /*
50 * Return an interpreted text description of a process termination event.
51 */
52 char *
ProcTerm(int ProcStat)53 ProcTerm(int ProcStat) {
54 int ExitCode, Signal;
55 static char buf[80];
56
57 if ( ProcStat == 0 || WIFEXITED(ProcStat) ) {
58 if ( !ProcStat )
59 ExitCode = 0; /* exit(0) */
60 else ExitCode = WEXITSTATUS(ProcStat); /* exit(code) */
61 sprintf(buf,"exit(%d)",ExitCode);
62
63 } else if ( WIFSIGNALED(ProcStat) ) {
64 Signal = WTERMSIG(ProcStat); /* Signalled or aborted */
65 sprintf(buf,"signal(%d)%s",Signal,WCOREDUMP(ProcStat)
66 ? ", core file written"
67 : "");
68
69 } else if ( WIFSTOPPED(ProcStat) ) {
70 Signal = WSTOPSIG(ProcStat); /* Stopped process */
71 sprintf(buf,"stopsig(%d)",Signal);
72
73 } else sprintf(buf,"Weird termination 0x%04X",ProcStat); /* Something weird */
74
75 return buf;
76 }
77
78 /* $Source: /home/cvs/wavplay/procterm.c,v $ */
79