xref: /titanic_53/usr/src/cmd/svr4pkg/pkgadd/quit.c (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
1*5c51f124SMoriah Waterland /*
2*5c51f124SMoriah Waterland  * CDDL HEADER START
3*5c51f124SMoriah Waterland  *
4*5c51f124SMoriah Waterland  * The contents of this file are subject to the terms of the
5*5c51f124SMoriah Waterland  * Common Development and Distribution License (the "License").
6*5c51f124SMoriah Waterland  * You may not use this file except in compliance with the License.
7*5c51f124SMoriah Waterland  *
8*5c51f124SMoriah Waterland  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5c51f124SMoriah Waterland  * or http://www.opensolaris.org/os/licensing.
10*5c51f124SMoriah Waterland  * See the License for the specific language governing permissions
11*5c51f124SMoriah Waterland  * and limitations under the License.
12*5c51f124SMoriah Waterland  *
13*5c51f124SMoriah Waterland  * When distributing Covered Code, include this CDDL HEADER in each
14*5c51f124SMoriah Waterland  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5c51f124SMoriah Waterland  * If applicable, add the following below this CDDL HEADER, with the
16*5c51f124SMoriah Waterland  * fields enclosed by brackets "[]" replaced with your own identifying
17*5c51f124SMoriah Waterland  * information: Portions Copyright [yyyy] [name of copyright owner]
18*5c51f124SMoriah Waterland  *
19*5c51f124SMoriah Waterland  * CDDL HEADER END
20*5c51f124SMoriah Waterland  */
21*5c51f124SMoriah Waterland 
22*5c51f124SMoriah Waterland /*
23*5c51f124SMoriah Waterland  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*5c51f124SMoriah Waterland  * Use is subject to license terms.
25*5c51f124SMoriah Waterland  */
26*5c51f124SMoriah Waterland 
27*5c51f124SMoriah Waterland /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28*5c51f124SMoriah Waterland /* All Rights Reserved */
29*5c51f124SMoriah Waterland 
30*5c51f124SMoriah Waterland #include <stdio.h>
31*5c51f124SMoriah Waterland #include <signal.h>
32*5c51f124SMoriah Waterland #include <stdlib.h>
33*5c51f124SMoriah Waterland #include <unistd.h>
34*5c51f124SMoriah Waterland #include <pkgdev.h>
35*5c51f124SMoriah Waterland #include <locale.h>
36*5c51f124SMoriah Waterland #include <libintl.h>
37*5c51f124SMoriah Waterland 
38*5c51f124SMoriah Waterland #include <pkglib.h>
39*5c51f124SMoriah Waterland #include <pkgweb.h>
40*5c51f124SMoriah Waterland #include <messages.h>
41*5c51f124SMoriah Waterland 
42*5c51f124SMoriah Waterland #include <libadm.h>
43*5c51f124SMoriah Waterland #include <libinst.h>
44*5c51f124SMoriah Waterland 
45*5c51f124SMoriah Waterland #include "quit.h"
46*5c51f124SMoriah Waterland 
47*5c51f124SMoriah Waterland /*
48*5c51f124SMoriah Waterland  * imported global variables
49*5c51f124SMoriah Waterland  */
50*5c51f124SMoriah Waterland 
51*5c51f124SMoriah Waterland /* imported from main.c */
52*5c51f124SMoriah Waterland 
53*5c51f124SMoriah Waterland extern struct pkgdev pkgdev;	/* holds info about the installation device */
54*5c51f124SMoriah Waterland 
55*5c51f124SMoriah Waterland extern int	npkgs;		/* the number of packages yet to be installed */
56*5c51f124SMoriah Waterland extern int	admnflag;	/* != 0 if any pkgop admin setting failed (4) */
57*5c51f124SMoriah Waterland extern int	doreboot;	/* != 0 if reboot required after installation */
58*5c51f124SMoriah Waterland extern int	failflag;	/* != 0 if fatal error has occurred (1) */
59*5c51f124SMoriah Waterland extern int	intrflag;	/* != 0 if user selected quit (3) */
60*5c51f124SMoriah Waterland extern int	ireboot;	/* != 0 if immediate reboot required */
61*5c51f124SMoriah Waterland extern int	nullflag;	/* != 0 if admin interaction required (5) */
62*5c51f124SMoriah Waterland extern int	warnflag;	/* != 0 if non-fatal error has occurred (2) */
63*5c51f124SMoriah Waterland 
64*5c51f124SMoriah Waterland /*
65*5c51f124SMoriah Waterland  * forward declarations
66*5c51f124SMoriah Waterland  */
67*5c51f124SMoriah Waterland 
68*5c51f124SMoriah Waterland static char		*dwnldTempDir = (char *)NULL;
69*5c51f124SMoriah Waterland static char		*idsName = (char *)NULL;
70*5c51f124SMoriah Waterland static char		*zoneTempDir = (char *)NULL;
71*5c51f124SMoriah Waterland static ckreturnFunc_t	*ckreturnFunc = (ckreturnFunc_t *)NULL;
72*5c51f124SMoriah Waterland static int		trapEntered = 0;
73*5c51f124SMoriah Waterland static intfRelocFunc_t	*intfRelocFunc = (intfRelocFunc_t *)NULL;
74*5c51f124SMoriah Waterland static void		trap(int signo);
75*5c51f124SMoriah Waterland static zoneList_t	zoneList = (zoneList_t)NULL;
76*5c51f124SMoriah Waterland 
77*5c51f124SMoriah Waterland /*
78*5c51f124SMoriah Waterland  * exported functions
79*5c51f124SMoriah Waterland  */
80*5c51f124SMoriah Waterland 
81*5c51f124SMoriah Waterland void		quit(int retcode);
82*5c51f124SMoriah Waterland void		quitSetCkreturnFunc(ckreturnFunc_t *a_ckreturnFunc);
83*5c51f124SMoriah Waterland void		quitSetDwnldTmpdir(char *a_dwnldTempDir);
84*5c51f124SMoriah Waterland void		quitSetIdsName(char *a_idsName);
85*5c51f124SMoriah Waterland void		quitSetZoneName(char *a_zoneName);
86*5c51f124SMoriah Waterland void		quitSetZoneTmpdir(char *z_zoneTempDir);
87*5c51f124SMoriah Waterland void		quitSetZonelist(zoneList_t a_zlst);
88*5c51f124SMoriah Waterland sighdlrFunc_t	*quitGetTrapHandler(void);
89*5c51f124SMoriah Waterland 
90*5c51f124SMoriah Waterland /*
91*5c51f124SMoriah Waterland  * *****************************************************************************
92*5c51f124SMoriah Waterland  * global external (public) functions
93*5c51f124SMoriah Waterland  * *****************************************************************************
94*5c51f124SMoriah Waterland  */
95*5c51f124SMoriah Waterland 
96*5c51f124SMoriah Waterland /*
97*5c51f124SMoriah Waterland  * Name:	quitGetTrapHandler
98*5c51f124SMoriah Waterland  * Description:	return address of this modules "signal trap" handler
99*5c51f124SMoriah Waterland  * Arguments:	void
100*5c51f124SMoriah Waterland  * Returns:	sighdlrFunc_t
101*5c51f124SMoriah Waterland  *			The address of the trap handler that can be passed to
102*5c51f124SMoriah Waterland  *			the signal() type system calls
103*5c51f124SMoriah Waterland  */
104*5c51f124SMoriah Waterland 
105*5c51f124SMoriah Waterland sighdlrFunc_t *
106*5c51f124SMoriah Waterland quitGetTrapHandler()
107*5c51f124SMoriah Waterland {
108*5c51f124SMoriah Waterland 	return (&trap);
109*5c51f124SMoriah Waterland }
110*5c51f124SMoriah Waterland 
111*5c51f124SMoriah Waterland /*
112*5c51f124SMoriah Waterland  * Name:	quitSetIdsName
113*5c51f124SMoriah Waterland  * Description:	set the input data stream name to use when quit() is called
114*5c51f124SMoriah Waterland  * Arguments:	a_idsName - pointer to string representing the input data
115*5c51f124SMoriah Waterland  *			stream object currently open
116*5c51f124SMoriah Waterland  *			== NULL - there is no input datastream object to use
117*5c51f124SMoriah Waterland  * Returns:	void
118*5c51f124SMoriah Waterland  * NOTE:	When quit() is called, if an input datastream object is set,
119*5c51f124SMoriah Waterland  *		quit will close the datastream and cleanup certain objects
120*5c51f124SMoriah Waterland  *		associated with the datastream
121*5c51f124SMoriah Waterland  */
122*5c51f124SMoriah Waterland 
123*5c51f124SMoriah Waterland void
124*5c51f124SMoriah Waterland quitSetIdsName(char *a_idsName)
125*5c51f124SMoriah Waterland {
126*5c51f124SMoriah Waterland 	idsName = a_idsName;
127*5c51f124SMoriah Waterland }
128*5c51f124SMoriah Waterland 
129*5c51f124SMoriah Waterland /*
130*5c51f124SMoriah Waterland  * Name:	quitSetIntfReloc
131*5c51f124SMoriah Waterland  * Description:	set the "intf_reloc" interface to run when quit() is called
132*5c51f124SMoriah Waterland  * Arguments:	a_intfReloc - pointer to function to call when quit() is called
133*5c51f124SMoriah Waterland  * Returns:	void
134*5c51f124SMoriah Waterland  * NOTE:	When quit() is called, if an "intf_reloc" function is set, quit
135*5c51f124SMoriah Waterland  *		will call that function to perform whatever operations it needs
136*5c51f124SMoriah Waterland  *		to perform - typically this is needed to run "intf_reloc" when
137*5c51f124SMoriah Waterland  *		pre-SVR4 packages have been installed
138*5c51f124SMoriah Waterland  */
139*5c51f124SMoriah Waterland 
140*5c51f124SMoriah Waterland void
141*5c51f124SMoriah Waterland quitSetIntfReloc(intfRelocFunc_t *a_intfReloc)
142*5c51f124SMoriah Waterland {
143*5c51f124SMoriah Waterland 	intfRelocFunc = a_intfReloc;
144*5c51f124SMoriah Waterland }
145*5c51f124SMoriah Waterland 
146*5c51f124SMoriah Waterland /*
147*5c51f124SMoriah Waterland  * Name:	quitSetCkreturnFunc
148*5c51f124SMoriah Waterland  * Description:	set the ckreturn() interface to call when quit() is called
149*5c51f124SMoriah Waterland  * Arguments:	a_ckreturnFunc - pointer to function to call when quit() is
150*5c51f124SMoriah Waterland  *			called
151*5c51f124SMoriah Waterland  * Returns:	void
152*5c51f124SMoriah Waterland  * NOTE:	When quit() is called if a "ckreturnfunc" is set, then the first
153*5c51f124SMoriah Waterland  *		action quit() takes is to call the "ckreturnfunc" specified with
154*5c51f124SMoriah Waterland  *		the value passed to quit as the first argument. Quit will then
155*5c51f124SMoriah Waterland  *		set the final return code to be used when exit() is called based
156*5c51f124SMoriah Waterland  *		on the contents of these global variables:
157*5c51f124SMoriah Waterland  *		 - admnflag - != 0 if any pkgop admin setting failed (4)
158*5c51f124SMoriah Waterland  *		 - doreboot - != 0 if reboot required after installation
159*5c51f124SMoriah Waterland  *		 - failflag - != 0 if fatal error has occurred (1)
160*5c51f124SMoriah Waterland  *		 - intrflag - != 0 if user selected quit (3)
161*5c51f124SMoriah Waterland  *		 - ireboot - != 0 if immediate reboot required
162*5c51f124SMoriah Waterland  *		 - nullflag - != 0 if admin interaction required (5)
163*5c51f124SMoriah Waterland  *		 - warnflag - != 0 if non-fatal error has occurred (2)
164*5c51f124SMoriah Waterland  */
165*5c51f124SMoriah Waterland 
166*5c51f124SMoriah Waterland void
167*5c51f124SMoriah Waterland quitSetCkreturnFunc(ckreturnFunc_t *a_ckreturnFunc)
168*5c51f124SMoriah Waterland {
169*5c51f124SMoriah Waterland 	ckreturnFunc = a_ckreturnFunc;
170*5c51f124SMoriah Waterland }
171*5c51f124SMoriah Waterland 
172*5c51f124SMoriah Waterland /*
173*5c51f124SMoriah Waterland  * Name:	quitSetZonelist
174*5c51f124SMoriah Waterland  * Description:	set the list of zones that are "locked" so that the zones can
175*5c51f124SMoriah Waterland  *		be unlocked if quit() is called to exit
176*5c51f124SMoriah Waterland  * Arguments:	a_zlst - list of zones that are "locked"
177*5c51f124SMoriah Waterland  * Returns:	void
178*5c51f124SMoriah Waterland  * NOTE:	When quit() is called, if this list is set, then z_unlock_zones
179*5c51f124SMoriah Waterland  *		is called to unlock all of the zones in the list. If this list
180*5c51f124SMoriah Waterland  *		is NOT set, then z_unlock_this_zone is called to unlock this
181*5c51f124SMoriah Waterland  *		zone.
182*5c51f124SMoriah Waterland  */
183*5c51f124SMoriah Waterland 
184*5c51f124SMoriah Waterland void
185*5c51f124SMoriah Waterland quitSetZonelist(zoneList_t a_zlst)
186*5c51f124SMoriah Waterland {
187*5c51f124SMoriah Waterland 	zoneList = a_zlst;
188*5c51f124SMoriah Waterland }
189*5c51f124SMoriah Waterland 
190*5c51f124SMoriah Waterland /*
191*5c51f124SMoriah Waterland  * Name:	quitSetZoneName
192*5c51f124SMoriah Waterland  * Description:	set the zone name the program is running in
193*5c51f124SMoriah Waterland  * Arguments:	a_zoneName - pointer to string representing the name of the zone
194*5c51f124SMoriah Waterland  *			that the program is running in
195*5c51f124SMoriah Waterland  * Returns:	void
196*5c51f124SMoriah Waterland  */
197*5c51f124SMoriah Waterland 
198*5c51f124SMoriah Waterland /* ARGSUSED */
199*5c51f124SMoriah Waterland void
200*5c51f124SMoriah Waterland quitSetZoneName(char *a_zoneName)
201*5c51f124SMoriah Waterland {
202*5c51f124SMoriah Waterland }
203*5c51f124SMoriah Waterland 
204*5c51f124SMoriah Waterland /*
205*5c51f124SMoriah Waterland  * Name:	quitSetZoneTmpdir
206*5c51f124SMoriah Waterland  * Description:	set the path to the "zone temporary directory" in use
207*5c51f124SMoriah Waterland  * Arguments:	a_zoneTempDir - pointer to string representing the full path to
208*5c51f124SMoriah Waterland  *			the temporary directory used to hold files used during
209*5c51f124SMoriah Waterland  *			zone operations
210*5c51f124SMoriah Waterland  * Returns:	void
211*5c51f124SMoriah Waterland  * NOTE:	If a zone temporary directory is set when quit() is called, the
212*5c51f124SMoriah Waterland  *		directory is recursively removed before quit() calls exit
213*5c51f124SMoriah Waterland  */
214*5c51f124SMoriah Waterland 
215*5c51f124SMoriah Waterland void
216*5c51f124SMoriah Waterland quitSetZoneTmpdir(char *a_zoneTempDir)
217*5c51f124SMoriah Waterland {
218*5c51f124SMoriah Waterland 	zoneTempDir = a_zoneTempDir;
219*5c51f124SMoriah Waterland }
220*5c51f124SMoriah Waterland 
221*5c51f124SMoriah Waterland /*
222*5c51f124SMoriah Waterland  * Name:	quitSetDwnldTmpdir
223*5c51f124SMoriah Waterland  * Description:	set the path to the "download temporary directory" in use
224*5c51f124SMoriah Waterland  * Arguments:	a_dwnldTempDir - pointer to string representing the full path to
225*5c51f124SMoriah Waterland  *			the temporary directory used to hold files used during
226*5c51f124SMoriah Waterland  *			download operations
227*5c51f124SMoriah Waterland  * Returns:	void
228*5c51f124SMoriah Waterland  * NOTE:	If a download temporary directory is set when quit() is called,
229*5c51f124SMoriah Waterland  *		the directory is recursively removed before quit() calls exit
230*5c51f124SMoriah Waterland  */
231*5c51f124SMoriah Waterland 
232*5c51f124SMoriah Waterland void
233*5c51f124SMoriah Waterland quitSetDwnldTmpdir(char *a_dwnldTempDir)
234*5c51f124SMoriah Waterland {
235*5c51f124SMoriah Waterland 	dwnldTempDir = a_dwnldTempDir;
236*5c51f124SMoriah Waterland }
237*5c51f124SMoriah Waterland 
238*5c51f124SMoriah Waterland /*
239*5c51f124SMoriah Waterland  * Name:	quit
240*5c51f124SMoriah Waterland  * Description:	cleanup and exit
241*5c51f124SMoriah Waterland  * Arguments:	a_retcode - the code to use to determine final exit status;
242*5c51f124SMoriah Waterland  *			if this is NOT "99" and if a "ckreturnFunc" is
243*5c51f124SMoriah Waterland  *			set, then that function is called with a_retcode
244*5c51f124SMoriah Waterland  *			to set the final exit status.
245*5c51f124SMoriah Waterland  *		Valid values are:
246*5c51f124SMoriah Waterland  *		0 - success
247*5c51f124SMoriah Waterland  *		1 - package operation failed (fatal error)
248*5c51f124SMoriah Waterland  *		2 - non-fatal error (warning)
249*5c51f124SMoriah Waterland  *		3 - user selected quit (operation interrupted)
250*5c51f124SMoriah Waterland  *		4 - admin settings prevented operation
251*5c51f124SMoriah Waterland  *		5 - interaction required and -n (non-interactive) specified
252*5c51f124SMoriah Waterland  *		"10" is added to indicate "immediate reboot required"
253*5c51f124SMoriah Waterland  *		"20" is be added to indicate "reboot after install required"
254*5c51f124SMoriah Waterland  *		99 - do not interpret the code - just exit "99"
255*5c51f124SMoriah Waterland  * Returns:	<<this function does not return - calls exit()>>
256*5c51f124SMoriah Waterland  */
257*5c51f124SMoriah Waterland 
258*5c51f124SMoriah Waterland void
259*5c51f124SMoriah Waterland quit(int a_retcode)
260*5c51f124SMoriah Waterland {
261*5c51f124SMoriah Waterland 	/* disable interrupts */
262*5c51f124SMoriah Waterland 
263*5c51f124SMoriah Waterland 	(void) signal(SIGINT, SIG_IGN);
264*5c51f124SMoriah Waterland 	(void) signal(SIGHUP, SIG_IGN);
265*5c51f124SMoriah Waterland 
266*5c51f124SMoriah Waterland 	if (!restore_local_fs()) {
267*5c51f124SMoriah Waterland 		progerr(ERR_CANNOT_RESTORE_LOCAL_FS);
268*5c51f124SMoriah Waterland 	}
269*5c51f124SMoriah Waterland 
270*5c51f124SMoriah Waterland 	/* process return code if not quit(99) */
271*5c51f124SMoriah Waterland 
272*5c51f124SMoriah Waterland 	if (a_retcode != 99) {
273*5c51f124SMoriah Waterland 		if (ckreturnFunc != (ckreturnFunc_t *)NULL) {
274*5c51f124SMoriah Waterland 			(ckreturnFunc)(a_retcode);
275*5c51f124SMoriah Waterland 		}
276*5c51f124SMoriah Waterland 		if (failflag) {
277*5c51f124SMoriah Waterland 			a_retcode = 1;
278*5c51f124SMoriah Waterland 		} else if (warnflag) {
279*5c51f124SMoriah Waterland 			a_retcode = 2;
280*5c51f124SMoriah Waterland 		} else if (intrflag) {
281*5c51f124SMoriah Waterland 			a_retcode = 3;
282*5c51f124SMoriah Waterland 		} else if (admnflag) {
283*5c51f124SMoriah Waterland 			a_retcode = 4;
284*5c51f124SMoriah Waterland 		} else if (nullflag) {
285*5c51f124SMoriah Waterland 			a_retcode = 5;
286*5c51f124SMoriah Waterland 		} else {
287*5c51f124SMoriah Waterland 			a_retcode = 0;
288*5c51f124SMoriah Waterland 		}
289*5c51f124SMoriah Waterland 		if (ireboot) {
290*5c51f124SMoriah Waterland 			a_retcode = (a_retcode % 10) + 20;
291*5c51f124SMoriah Waterland 		}
292*5c51f124SMoriah Waterland 		if (doreboot) {
293*5c51f124SMoriah Waterland 			a_retcode = (a_retcode % 10) + 10;
294*5c51f124SMoriah Waterland 		}
295*5c51f124SMoriah Waterland 	}
296*5c51f124SMoriah Waterland 
297*5c51f124SMoriah Waterland 	if (doreboot || ireboot) {
298*5c51f124SMoriah Waterland 		ptext(stderr, MSG_REBOOT);
299*5c51f124SMoriah Waterland 	}
300*5c51f124SMoriah Waterland 
301*5c51f124SMoriah Waterland 	(void) chdir("/");
302*5c51f124SMoriah Waterland 
303*5c51f124SMoriah Waterland 	/* if set remove download temporary directory */
304*5c51f124SMoriah Waterland 
305*5c51f124SMoriah Waterland 	if (dwnldTempDir != (char *)NULL) {
306*5c51f124SMoriah Waterland 		echoDebug(DBG_REMOVING_DWNLD_TMPDIR, dwnldTempDir);
307*5c51f124SMoriah Waterland 		(void) rrmdir(dwnldTempDir);
308*5c51f124SMoriah Waterland 		dwnldTempDir = (char *)NULL;
309*5c51f124SMoriah Waterland 	}
310*5c51f124SMoriah Waterland 
311*5c51f124SMoriah Waterland 	/* if set remove zone temporary directory */
312*5c51f124SMoriah Waterland 
313*5c51f124SMoriah Waterland 	if (zoneTempDir != (char *)NULL) {
314*5c51f124SMoriah Waterland 		echoDebug(DBG_REMOVING_ZONE_TMPDIR, zoneTempDir);
315*5c51f124SMoriah Waterland 		(void) rrmdir(zoneTempDir);
316*5c51f124SMoriah Waterland 		zoneTempDir = (char *)NULL;
317*5c51f124SMoriah Waterland 	}
318*5c51f124SMoriah Waterland 
319*5c51f124SMoriah Waterland 	/* close and cleanup if input datastream is set */
320*5c51f124SMoriah Waterland 
321*5c51f124SMoriah Waterland 	if (idsName != (char *)NULL) { /* datastream */
322*5c51f124SMoriah Waterland 		if (pkgdev.dirname != NULL) {
323*5c51f124SMoriah Waterland 			echoDebug(DBG_REMOVING_DSTREAM_TMPDIR, pkgdev.dirname);
324*5c51f124SMoriah Waterland 			(void) rrmdir(pkgdev.dirname);  /* from tempnam */
325*5c51f124SMoriah Waterland 		}
326*5c51f124SMoriah Waterland 		/*
327*5c51f124SMoriah Waterland 		 * cleanup after a web-based install.
328*5c51f124SMoriah Waterland 		 * web-based install failures
329*5c51f124SMoriah Waterland 		 * are indicated by exit codes 10-98
330*5c51f124SMoriah Waterland 		 * exit code 99 is fatal error exit.
331*5c51f124SMoriah Waterland 		 */
332*5c51f124SMoriah Waterland 		if (pkgdev.pathname != NULL && is_web_install() &&
333*5c51f124SMoriah Waterland 			(a_retcode == 0 ||
334*5c51f124SMoriah Waterland 				(a_retcode >= 10 && a_retcode < 99))) {
335*5c51f124SMoriah Waterland 			(void) web_cleanup();
336*5c51f124SMoriah Waterland 		}
337*5c51f124SMoriah Waterland 		(void) ds_close(1);
338*5c51f124SMoriah Waterland 	} else if (pkgdev.mount) {
339*5c51f124SMoriah Waterland 		(void) pkgumount(&pkgdev);
340*5c51f124SMoriah Waterland 	}
341*5c51f124SMoriah Waterland 
342*5c51f124SMoriah Waterland 	/*
343*5c51f124SMoriah Waterland 	 * issue final exit message depending on number of packages left
344*5c51f124SMoriah Waterland 	 * to process
345*5c51f124SMoriah Waterland 	 */
346*5c51f124SMoriah Waterland 
347*5c51f124SMoriah Waterland 	if (npkgs == 1) {
348*5c51f124SMoriah Waterland 		echo(MSG_1_PKG_NOT_PROCESSED);
349*5c51f124SMoriah Waterland 	} else if (npkgs) {
350*5c51f124SMoriah Waterland 		echo(MSG_N_PKGS_NOT_PROCESSED, npkgs);
351*5c51f124SMoriah Waterland 	}
352*5c51f124SMoriah Waterland 
353*5c51f124SMoriah Waterland 	/* call intf_reloc function if registered */
354*5c51f124SMoriah Waterland 
355*5c51f124SMoriah Waterland 	if (intfRelocFunc != (intfRelocFunc_t *)NULL) {
356*5c51f124SMoriah Waterland 		(intfRelocFunc)();
357*5c51f124SMoriah Waterland 	}
358*5c51f124SMoriah Waterland 
359*5c51f124SMoriah Waterland 	/* if a zone list exists, unlock all zones */
360*5c51f124SMoriah Waterland 
361*5c51f124SMoriah Waterland 	if (zoneList != (zoneList_t)NULL) {
362*5c51f124SMoriah Waterland 		(void) z_unlock_zones(zoneList, ZLOCKS_ALL);
363*5c51f124SMoriah Waterland 	} else {
364*5c51f124SMoriah Waterland 		(void) z_unlock_this_zone(ZLOCKS_ALL);
365*5c51f124SMoriah Waterland 	}
366*5c51f124SMoriah Waterland 
367*5c51f124SMoriah Waterland 	/* final exit debugging message */
368*5c51f124SMoriah Waterland 
369*5c51f124SMoriah Waterland 	echoDebug(DBG_EXIT_WITH_CODE, a_retcode);
370*5c51f124SMoriah Waterland 
371*5c51f124SMoriah Waterland 	exit(a_retcode);
372*5c51f124SMoriah Waterland 	/* NOTREACHED */
373*5c51f124SMoriah Waterland }
374*5c51f124SMoriah Waterland 
375*5c51f124SMoriah Waterland /*
376*5c51f124SMoriah Waterland  * *****************************************************************************
377*5c51f124SMoriah Waterland  * static internal (private) functions
378*5c51f124SMoriah Waterland  * *****************************************************************************
379*5c51f124SMoriah Waterland  */
380*5c51f124SMoriah Waterland 
381*5c51f124SMoriah Waterland /*
382*5c51f124SMoriah Waterland  * Name:	trap
383*5c51f124SMoriah Waterland  * Description:	signal handler connected via quitGetTrapHandler()
384*5c51f124SMoriah Waterland  * Arguments:	signo - [RO, *RO] - (int)
385*5c51f124SMoriah Waterland  *			Integer representing the signal that caused the trap
386*5c51f124SMoriah Waterland  *			to this function to occur
387*5c51f124SMoriah Waterland  * Returns:	<< NONE >>
388*5c51f124SMoriah Waterland  * NOTE:	This function exits the program after doing mandatory cleanup.
389*5c51f124SMoriah Waterland  * NOTE:	Even though quit() should NOT return, there is a call to _exit()
390*5c51f124SMoriah Waterland  *		put after each call to quit() just in case quit() ever returned
391*5c51f124SMoriah Waterland  *		by mistake.
392*5c51f124SMoriah Waterland  */
393*5c51f124SMoriah Waterland 
394*5c51f124SMoriah Waterland static void
395*5c51f124SMoriah Waterland trap(int signo)
396*5c51f124SMoriah Waterland {
397*5c51f124SMoriah Waterland 	/* prevent reentrance */
398*5c51f124SMoriah Waterland 
399*5c51f124SMoriah Waterland 	if (trapEntered++ != 0) {
400*5c51f124SMoriah Waterland 		return;
401*5c51f124SMoriah Waterland 	}
402*5c51f124SMoriah Waterland 
403*5c51f124SMoriah Waterland 	if ((signo == SIGINT) || (signo == SIGHUP)) {
404*5c51f124SMoriah Waterland 		quit(3);
405*5c51f124SMoriah Waterland 		_exit(3);
406*5c51f124SMoriah Waterland 	}
407*5c51f124SMoriah Waterland 	quit(1);
408*5c51f124SMoriah Waterland 	_exit(1);
409*5c51f124SMoriah Waterland }
410