Home | History | Annotate | Line # | Download | only in pax
pax.c revision 1.3
      1  1.1      jtc /*-
      2  1.1      jtc  * Copyright (c) 1992 Keith Muller.
      3  1.1      jtc  * Copyright (c) 1992, 1993
      4  1.1      jtc  *	The Regents of the University of California.  All rights reserved.
      5  1.1      jtc  *
      6  1.1      jtc  * This code is derived from software contributed to Berkeley by
      7  1.1      jtc  * Keith Muller of the University of California, San Diego.
      8  1.1      jtc  *
      9  1.1      jtc  * Redistribution and use in source and binary forms, with or without
     10  1.1      jtc  * modification, are permitted provided that the following conditions
     11  1.1      jtc  * are met:
     12  1.1      jtc  * 1. Redistributions of source code must retain the above copyright
     13  1.1      jtc  *    notice, this list of conditions and the following disclaimer.
     14  1.1      jtc  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1      jtc  *    notice, this list of conditions and the following disclaimer in the
     16  1.1      jtc  *    documentation and/or other materials provided with the distribution.
     17  1.1      jtc  * 3. All advertising materials mentioning features or use of this software
     18  1.1      jtc  *    must display the following acknowledgement:
     19  1.1      jtc  *	This product includes software developed by the University of
     20  1.1      jtc  *	California, Berkeley and its contributors.
     21  1.1      jtc  * 4. Neither the name of the University nor the names of its contributors
     22  1.1      jtc  *    may be used to endorse or promote products derived from this software
     23  1.1      jtc  *    without specific prior written permission.
     24  1.1      jtc  *
     25  1.1      jtc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26  1.1      jtc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27  1.1      jtc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28  1.1      jtc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29  1.1      jtc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30  1.1      jtc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31  1.1      jtc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32  1.1      jtc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33  1.1      jtc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34  1.1      jtc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35  1.1      jtc  * SUCH DAMAGE.
     36  1.1      jtc  */
     37  1.1      jtc 
     38  1.1      jtc #ifndef lint
     39  1.1      jtc static char copyright[] =
     40  1.1      jtc "@(#) Copyright (c) 1992, 1993\n\
     41  1.1      jtc 	The Regents of the University of California.  All rights reserved.\n";
     42  1.1      jtc #endif /* not lint */
     43  1.1      jtc 
     44  1.1      jtc #ifndef lint
     45  1.2      jtc /*static char sccsid[] = "from: @(#)pax.c	8.2 (Berkeley) 4/18/94";*/
     46  1.3  mycroft static char *rcsid = "$Id: pax.c,v 1.3 1994/06/14 00:43:06 mycroft Exp $";
     47  1.1      jtc #endif /* not lint */
     48  1.1      jtc 
     49  1.1      jtc #include <stdio.h>
     50  1.1      jtc #include <sys/types.h>
     51  1.1      jtc #include <sys/param.h>
     52  1.1      jtc #include <sys/stat.h>
     53  1.1      jtc #include <sys/time.h>
     54  1.1      jtc #include <sys/resource.h>
     55  1.1      jtc #include <signal.h>
     56  1.1      jtc #include <unistd.h>
     57  1.1      jtc #include <stdlib.h>
     58  1.1      jtc #include <errno.h>
     59  1.1      jtc #include "pax.h"
     60  1.1      jtc #include "extern.h"
     61  1.1      jtc static int gen_init __P((void));
     62  1.1      jtc 
     63  1.1      jtc /*
     64  1.1      jtc  * PAX main routines, general globals and some simple start up routines
     65  1.1      jtc  */
     66  1.1      jtc 
     67  1.1      jtc /*
     68  1.1      jtc  * Variables that can be accessed by any routine within pax
     69  1.1      jtc  */
     70  1.1      jtc int	act = DEFOP;		/* read/write/append/copy */
     71  1.1      jtc FSUB	*frmt = NULL;		/* archive format type */
     72  1.1      jtc int	cflag;			/* match all EXCEPT pattern/file */
     73  1.1      jtc int	dflag;			/* directory member match only  */
     74  1.1      jtc int	iflag;			/* interactive file/archive rename */
     75  1.1      jtc int	kflag;			/* do not overwrite existing files */
     76  1.1      jtc int	lflag;			/* use hard links when possible */
     77  1.1      jtc int	nflag;			/* select first archive member match */
     78  1.1      jtc int	tflag;			/* restore access time after read */
     79  1.1      jtc int	uflag;			/* ignore older modification time files */
     80  1.1      jtc int	vflag;			/* produce verbose output */
     81  1.1      jtc int	Dflag;			/* same as uflag except inode change time */
     82  1.1      jtc int	Hflag;			/* follow command line symlinks (write only) */
     83  1.1      jtc int	Lflag;			/* follow symlinks when writing */
     84  1.1      jtc int	Xflag;			/* archive files with same device id only */
     85  1.1      jtc int	Yflag;			/* same as Dflg except after name mode */
     86  1.1      jtc int	Zflag;			/* same as uflg except after name mode */
     87  1.1      jtc int	vfpart;			/* is partial verbose output in progress */
     88  1.1      jtc int	patime = 1;		/* preserve file access time */
     89  1.1      jtc int	pmtime = 1;		/* preserve file modification times */
     90  1.1      jtc int	pmode;			/* preserve file mode bits */
     91  1.1      jtc int	pids;			/* preserve file uid/gid */
     92  1.1      jtc int	exit_val;		/* exit value */
     93  1.1      jtc int	docrc;			/* check/create file crc */
     94  1.1      jtc char	*dirptr;		/* destination dir in a copy */
     95  1.1      jtc char	*ltmfrmt;		/* -v locale time format (if any) */
     96  1.1      jtc char	*argv0;			/* root of argv[0] */
     97  1.1      jtc sigset_t s_mask;		/* signal mask for cleanup critical sect */
     98  1.1      jtc 
     99  1.1      jtc /*
    100  1.1      jtc  *	PAX - Portable Archive Interchange
    101  1.1      jtc  *
    102  1.1      jtc  * 	A utility to read, write, and write lists of the members of archive
    103  1.1      jtc  *	files and copy directory hierarchies. A variety of archive formats
    104  1.1      jtc  *	are supported (some are described in POSIX 1003.1 10.1):
    105  1.1      jtc  *
    106  1.1      jtc  *		ustar - 10.1.1 extended tar interchange format
    107  1.1      jtc  *		cpio  - 10.1.2 extended cpio interchange format
    108  1.1      jtc  *		tar - old BSD 4.3 tar format
    109  1.1      jtc  *		binary cpio - old cpio with binary header format
    110  1.1      jtc  *		sysVR4 cpio -  with and without CRC
    111  1.1      jtc  *
    112  1.1      jtc  * This version is a superset of IEEE Std 1003.2b-d3
    113  1.1      jtc  *
    114  1.1      jtc  * Summary of Extensions to the IEEE Standard:
    115  1.1      jtc  *
    116  1.1      jtc  * 1	READ ENHANCEMENTS
    117  1.1      jtc  * 1.1	Operations which read archives will continue to operate even when
    118  1.1      jtc  *	processing archives which may be damaged, truncated, or fail to meet
    119  1.1      jtc  *	format specs in several different ways. Damaged sections of archives
    120  1.1      jtc  *	are detected and avoided if possible. Attempts will be made to resync
    121  1.1      jtc  *	archive read operations even with badly damaged media.
    122  1.1      jtc  * 1.2	Blocksize requirements are not strictly enforced on archive read.
    123  1.1      jtc  *	Tapes which have variable sized records can be read without errors.
    124  1.1      jtc  * 1.3	The user can specify via the non-standard option flag -E if error
    125  1.1      jtc  *	resync operation should stop on a media error, try a specified number
    126  1.1      jtc  *	of times to correct, or try to correct forever.
    127  1.1      jtc  * 1.4	Sparse files (lseek holes) stored on the archive (but stored with blocks
    128  1.1      jtc  *	of all zeros will be restored with holes appropriate for the target
    129  1.1      jtc  *	filesystem
    130  1.1      jtc  * 1.5	The user is notified whenever something is found during archive
    131  1.1      jtc  *	read operations which violates spec (but the read will continue).
    132  1.1      jtc  * 1.6	Multiple archive volumes can be read and may span over different
    133  1.1      jtc  *	archive devices
    134  1.1      jtc  * 1.7	Rigidly restores all file attributes exactly as they are stored on the
    135  1.1      jtc  *	archive.
    136  1.1      jtc  * 1.8	Modification change time ranges can be specified via multiple -T
    137  1.1      jtc  *	options. These allow a user to select files whose modification time
    138  1.1      jtc  *	lies within a specific time range.
    139  1.1      jtc  * 1.9	Files can be selected based on owner (user name or uid) via one or more
    140  1.1      jtc  *	-U options.
    141  1.1      jtc  * 1.10	Files can be selected based on group (group name or gid) via one o
    142  1.1      jtc  *	more -G options.
    143  1.1      jtc  * 1.11	File modification time can be checked against exisiting file after
    144  1.1      jtc  *	name modification (-Z)
    145  1.1      jtc  *
    146  1.1      jtc  * 2	WRITE ENHANCEMENTS
    147  1.1      jtc  * 2.1	Write operation will stop instead of allowing a user to create a flawed
    148  1.1      jtc  *	flawed archive (due to any problem).
    149  1.1      jtc  * 2.2	Archives writtens by pax are forced to strictly conform to both the
    150  1.1      jtc  *	archive and pax the spceific format specifications.
    151  1.1      jtc  * 2.3	Blocking size and format is rigidly enforced on writes.
    152  1.1      jtc  * 2.4	Formats which may exhibit header overflow problems (they have fields
    153  1.1      jtc  *	too small for large file systems, such as inode number storage), use
    154  1.1      jtc  *	routines designed to repair this problem. These techniques still
    155  1.1      jtc  *	conform to both pax and format specifications, but no longer truncate
    156  1.1      jtc  *	these fields. This removes any restrictions on using these archive
    157  1.1      jtc  *	formats on large file systems.
    158  1.1      jtc  * 2.5	Multiple archive volumes can be written and may span over different
    159  1.1      jtc  *	archive devices
    160  1.1      jtc  * 2.6	A archive volume record limit allows the user to specify the number
    161  1.1      jtc  *	of bytes stored on an archive volume. When reached the user is
    162  1.1      jtc  *	prompted for the next archive volume. This is specified with the
    163  1.1      jtc  *	non-standard -B flag. THe limit is rounded up to the next blocksize.
    164  1.1      jtc  * 2.7	All archive padding during write use zero filled sections. This makes
    165  1.1      jtc  *	it much easier to pull data out of flawed archive during read
    166  1.1      jtc  *	operations.
    167  1.1      jtc  * 2.8	Access time reset with the -t applies to all file nodes (including
    168  1.1      jtc  *	directories).
    169  1.1      jtc  * 2.9	Symbolic links can be followed with -L (optional in the spec).
    170  1.1      jtc  * 2.10	Modification or inode change time ranges can be specified via
    171  1.1      jtc  *	multiple -T options. These allow a user to select files whose
    172  1.1      jtc  *	modification or inode change time lies within a specific time range.
    173  1.1      jtc  * 2.11	Files can be selected based on owner (user name or uid) via one or more
    174  1.1      jtc  *	-U options.
    175  1.1      jtc  * 2.12	Files can be selected based on group (group name or gid) via one o
    176  1.1      jtc  *	more -G options.
    177  1.1      jtc  * 2.13	Symlinks which appear on the command line can be followed (without
    178  1.1      jtc  *	following other symlinks; -H flag)
    179  1.1      jtc  *
    180  1.1      jtc  * 3	COPY ENHANCEMENTS
    181  1.1      jtc  * 3.1	Sparse files (lseek holes) can be copied without expanding the holes
    182  1.1      jtc  *	into zero filled blocks. The file copy is created with holes which are
    183  1.1      jtc  *	appropriate for the target filesystem
    184  1.1      jtc  * 3.2	Access time as well as modification time on copied file trees can be
    185  1.1      jtc  *	preserved with the appropriate -p options.
    186  1.1      jtc  * 3.3	Access time reset with the -t applies to all file nodes (including
    187  1.1      jtc  *	directories).
    188  1.1      jtc  * 3.4	Symbolic links can be followed with -L (optional in the spec).
    189  1.1      jtc  * 3.5	Modification or inode change time ranges can be specified via
    190  1.1      jtc  *	multiple -T options. These allow a user to select files whose
    191  1.1      jtc  *	modification or inode change time lies within a specific time range.
    192  1.1      jtc  * 3.6	Files can be selected based on owner (user name or uid) via one or more
    193  1.1      jtc  *	-U options.
    194  1.1      jtc  * 3.7	Files can be selected based on group (group name or gid) via one o
    195  1.1      jtc  *	more -G options.
    196  1.1      jtc  * 3.8	Symlinks which appear on the command line can be followed (without
    197  1.1      jtc  *	following other symlinks; -H flag)
    198  1.1      jtc  * 3.9  File inode change time can be checked against exisiting file before
    199  1.1      jtc  *	name modification (-D)
    200  1.1      jtc  * 3.10 File inode change time can be checked against exisiting file after
    201  1.1      jtc  *	name modification (-Y)
    202  1.1      jtc  * 3.11	File modification time can be checked against exisiting file after
    203  1.1      jtc  *	name modification (-Z)
    204  1.1      jtc  *
    205  1.1      jtc  * 4	GENERAL ENHANCEMENTS
    206  1.1      jtc  * 4.1	Internal structure is designed to isolate format dependent and
    207  1.1      jtc  *	independent functions. Formats are selected via a format driver table.
    208  1.1      jtc  *	This encourages the addition of new archive formats by only having to
    209  1.1      jtc  *	write those routines which id, read and write the archive header.
    210  1.1      jtc  */
    211  1.1      jtc 
    212  1.1      jtc /*
    213  1.1      jtc  * main()
    214  1.1      jtc  *	parse options, set up and operate as specified by the user.
    215  1.1      jtc  *	any operational flaw will set exit_val to non-zero
    216  1.1      jtc  * Return: 0 if ok, 1 otherwise
    217  1.1      jtc  */
    218  1.1      jtc 
    219  1.1      jtc #if __STDC__
    220  1.1      jtc int
    221  1.1      jtc main(int argc, char **argv)
    222  1.1      jtc #else
    223  1.1      jtc int
    224  1.1      jtc main(argc, argv)
    225  1.1      jtc 	int argc;
    226  1.1      jtc 	char **argv;
    227  1.1      jtc #endif
    228  1.1      jtc {
    229  1.1      jtc 	/*
    230  1.1      jtc 	 * parse options, determine operational mode, general init
    231  1.1      jtc 	 */
    232  1.1      jtc 	options(argc, argv);
    233  1.1      jtc         if ((gen_init() < 0) || (tty_init() < 0))
    234  1.1      jtc 		return(exit_val);
    235  1.1      jtc 
    236  1.1      jtc 	/*
    237  1.1      jtc 	 * select a primary operation mode
    238  1.1      jtc 	 */
    239  1.1      jtc 	switch(act) {
    240  1.1      jtc 	case EXTRACT:
    241  1.1      jtc 		extract();
    242  1.1      jtc 		break;
    243  1.1      jtc 	case ARCHIVE:
    244  1.1      jtc 		archive();
    245  1.1      jtc 		break;
    246  1.1      jtc 	case APPND:
    247  1.1      jtc 		append();
    248  1.1      jtc 		break;
    249  1.1      jtc 	case COPY:
    250  1.1      jtc 		copy();
    251  1.1      jtc 		break;
    252  1.1      jtc 	default:
    253  1.1      jtc 	case LIST:
    254  1.1      jtc 		list();
    255  1.1      jtc 		break;
    256  1.1      jtc 	}
    257  1.1      jtc 	return(exit_val);
    258  1.1      jtc }
    259  1.1      jtc 
    260  1.1      jtc /*
    261  1.1      jtc  * sig_cleanup()
    262  1.1      jtc  *	when interrupted we try to do whatever delayed processing we can.
    263  1.1      jtc  *	This is not critical, but we really ought to limit our damage when we
    264  1.1      jtc  *	are aborted by the user.
    265  1.1      jtc  * Return:
    266  1.1      jtc  *	never....
    267  1.1      jtc  */
    268  1.1      jtc 
    269  1.1      jtc #if __STDC__
    270  1.1      jtc void
    271  1.1      jtc sig_cleanup(int which_sig)
    272  1.1      jtc #else
    273  1.1      jtc void
    274  1.1      jtc sig_cleanup(which_sig)
    275  1.1      jtc 	int which_sig;
    276  1.1      jtc #endif
    277  1.1      jtc {
    278  1.1      jtc 	/*
    279  1.1      jtc 	 * restore modes and times for any dirs we may have created
    280  1.1      jtc 	 * or any dirs we may have read. Set vflag and vfpart so the user
    281  1.1      jtc 	 * will clearly see the message on a line by itself.
    282  1.1      jtc 	 */
    283  1.1      jtc 	vflag = vfpart = 1;
    284  1.1      jtc 	if (which_sig == SIGXCPU)
    285  1.1      jtc 		warn(0, "Cpu time limit reached, cleaning up.");
    286  1.1      jtc 	else
    287  1.1      jtc 		warn(0, "Signal caught, cleaning up.");
    288  1.1      jtc 
    289  1.1      jtc 	ar_close();
    290  1.1      jtc 	proc_dir();
    291  1.1      jtc 	if (tflag)
    292  1.1      jtc 		atdir_end();
    293  1.1      jtc 	exit(1);
    294  1.1      jtc }
    295  1.1      jtc 
    296  1.1      jtc /*
    297  1.1      jtc  * gen_init()
    298  1.1      jtc  *	general setup routines. Not all are required, but they really help
    299  1.1      jtc  *	when dealing with a medium to large sized archives.
    300  1.1      jtc  */
    301  1.1      jtc 
    302  1.1      jtc #if __STDC__
    303  1.1      jtc static int
    304  1.1      jtc gen_init(void)
    305  1.1      jtc #else
    306  1.1      jtc static int
    307  1.1      jtc gen_init()
    308  1.1      jtc #endif
    309  1.1      jtc {
    310  1.1      jtc 	struct rlimit reslimit;
    311  1.1      jtc 	struct sigaction n_hand;
    312  1.1      jtc 	struct sigaction o_hand;
    313  1.1      jtc 
    314  1.1      jtc 	/*
    315  1.1      jtc 	 * Really needed to handle large archives. We can run out of memory for
    316  1.1      jtc 	 * internal tables really fast when we have a whole lot of files...
    317  1.1      jtc 	 */
    318  1.1      jtc 	if (getrlimit(RLIMIT_DATA , &reslimit) == 0){
    319  1.1      jtc 		reslimit.rlim_cur = reslimit.rlim_max;
    320  1.1      jtc 		(void)setrlimit(RLIMIT_DATA , &reslimit);
    321  1.1      jtc 	}
    322  1.1      jtc 
    323  1.1      jtc 	/*
    324  1.1      jtc 	 * should file size limits be waived? if the os limits us, this is
    325  1.1      jtc 	 * needed if we want to write a large archive
    326  1.1      jtc 	 */
    327  1.1      jtc 	if (getrlimit(RLIMIT_FSIZE , &reslimit) == 0){
    328  1.1      jtc 		reslimit.rlim_cur = reslimit.rlim_max;
    329  1.1      jtc 		(void)setrlimit(RLIMIT_FSIZE , &reslimit);
    330  1.1      jtc 	}
    331  1.1      jtc 
    332  1.1      jtc 	/*
    333  1.1      jtc 	 * increase the size the stack can grow to
    334  1.1      jtc 	 */
    335  1.1      jtc 	if (getrlimit(RLIMIT_STACK , &reslimit) == 0){
    336  1.1      jtc 		reslimit.rlim_cur = reslimit.rlim_max;
    337  1.1      jtc 		(void)setrlimit(RLIMIT_STACK , &reslimit);
    338  1.1      jtc 	}
    339  1.1      jtc 
    340  1.1      jtc 	/*
    341  1.1      jtc 	 * not really needed, but doesn't hurt
    342  1.1      jtc 	 */
    343  1.1      jtc 	if (getrlimit(RLIMIT_RSS , &reslimit) == 0){
    344  1.1      jtc 		reslimit.rlim_cur = reslimit.rlim_max;
    345  1.1      jtc 		(void)setrlimit(RLIMIT_RSS , &reslimit);
    346  1.1      jtc 	}
    347  1.1      jtc 
    348  1.1      jtc 	/*
    349  1.1      jtc 	 * Handle posix locale
    350  1.1      jtc 	 *
    351  1.1      jtc 	 * set user defines time printing format for -v option
    352  1.1      jtc 	 */
    353  1.1      jtc 	ltmfrmt = getenv("LC_TIME");
    354  1.1      jtc 
    355  1.1      jtc 	/*
    356  1.1      jtc 	 * signal handling to reset stored directory times and modes. Since
    357  1.1      jtc 	 * we deal with broken pipes via failed writes we ignore it. We also
    358  1.1      jtc 	 * deal with any file size limit thorugh failed writes. Cpu time
    359  1.1      jtc 	 * limits are caught and a cleanup is forced.
    360  1.1      jtc 	 */
    361  1.1      jtc 	if ((sigemptyset(&s_mask) < 0) || (sigaddset(&s_mask, SIGTERM) < 0) ||
    362  1.1      jtc 	    (sigaddset(&s_mask,SIGINT) < 0)||(sigaddset(&s_mask,SIGHUP) < 0) ||
    363  1.1      jtc 	    (sigaddset(&s_mask,SIGPIPE) < 0)||(sigaddset(&s_mask,SIGQUIT)<0) ||
    364  1.1      jtc 	    (sigaddset(&s_mask,SIGXCPU) < 0)||(sigaddset(&s_mask,SIGXFSZ)<0)) {
    365  1.1      jtc 		warn(1, "Unable to set up signal mask");
    366  1.1      jtc 		return(-1);
    367  1.1      jtc 	}
    368  1.1      jtc 	n_hand.sa_mask = s_mask;
    369  1.1      jtc 	n_hand.sa_flags = 0;
    370  1.1      jtc 	n_hand.sa_handler = sig_cleanup;
    371  1.1      jtc 
    372  1.1      jtc 	if ((sigaction(SIGHUP, &n_hand, &o_hand) < 0) &&
    373  1.1      jtc 	    (o_hand.sa_handler == SIG_IGN) &&
    374  1.1      jtc 	    (sigaction(SIGHUP, &o_hand, &o_hand) < 0))
    375  1.1      jtc 		goto out;
    376  1.1      jtc 
    377  1.1      jtc 	if ((sigaction(SIGTERM, &n_hand, &o_hand) < 0) &&
    378  1.1      jtc 	    (o_hand.sa_handler == SIG_IGN) &&
    379  1.1      jtc 	    (sigaction(SIGTERM, &o_hand, &o_hand) < 0))
    380  1.1      jtc 		goto out;
    381  1.1      jtc 
    382  1.1      jtc 	if ((sigaction(SIGINT, &n_hand, &o_hand) < 0) &&
    383  1.1      jtc 	    (o_hand.sa_handler == SIG_IGN) &&
    384  1.1      jtc 	    (sigaction(SIGINT, &o_hand, &o_hand) < 0))
    385  1.1      jtc 		goto out;
    386  1.1      jtc 
    387  1.1      jtc 	if ((sigaction(SIGQUIT, &n_hand, &o_hand) < 0) &&
    388  1.1      jtc 	    (o_hand.sa_handler == SIG_IGN) &&
    389  1.1      jtc 	    (sigaction(SIGQUIT, &o_hand, &o_hand) < 0))
    390  1.1      jtc 		goto out;
    391  1.1      jtc 
    392  1.1      jtc 	if ((sigaction(SIGXCPU, &n_hand, &o_hand) < 0) &&
    393  1.1      jtc 	    (o_hand.sa_handler == SIG_IGN) &&
    394  1.1      jtc 	    (sigaction(SIGXCPU, &o_hand, &o_hand) < 0))
    395  1.1      jtc 		goto out;
    396  1.1      jtc 
    397  1.1      jtc 	n_hand.sa_handler = SIG_IGN;
    398  1.1      jtc 	if ((sigaction(SIGPIPE, &n_hand, &o_hand) < 0) ||
    399  1.1      jtc 	    (sigaction(SIGXFSZ, &n_hand, &o_hand) < 0))
    400  1.1      jtc 		goto out;
    401  1.1      jtc 	return(0);
    402  1.1      jtc 
    403  1.1      jtc     out:
    404  1.1      jtc 	syswarn(1, errno, "Unable to set up signal handler");
    405  1.1      jtc 	return(-1);
    406  1.1      jtc }
    407