File: cleanup.c

package info (click to toggle)
cti-ifhp 2.2.8-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 904 kB
  • ctags: 673
  • sloc: ansic: 4,916; sh: 1,539; makefile: 287; perl: 99
file content (41 lines) | stat: -rw-r--r-- 925 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**************************************************************************
 * LPRng IFHP Filter
 * Copyright 1994-1997 Patrick Powell, San Diego, CA <papowell@astart.com>
 *
 * Based on the CTI printer filters.
 *  See COPYRIGHT for details.
 *
 * cleanup.c,v 3.2 1998/03/19 14:21:33 papowell Exp
 */

#include "portable.h"
#include "common.h"
#include "hp4.h"

static int exitval;

void cleanup(sig)
int sig;
{
	log(4,"Signal %s received-entering cleanup", Sigstr(sig) );

	if( monitpid > 0 ) {
        log(3,"Father murders %d", monitpid);
        kill(monitpid,SIGTERM);
        kill(monitpid,SIGCONT);
	}
	if( accntpid > 0 ) {
        log(3,"Father murders %d", accntpid);
        kill(accntpid,SIGTERM);
        kill(accntpid,SIGCONT);
	}
	if( exitval ){
		fexit(exitval);
	} else if( getpid() != filterpid ){
		/* we are the child */
		exit(0);
    }
	exitval = FILTRETRY;
	log(3,"Job Interrupted");
	exit(exitval);
}