/* $NetBSD: timed_wait.c,v 1.1.1.3 2006/07/19 01:17:56 rpaulo Exp $ */ /*++ /* NAME /* timed_wait 3 /* SUMMARY /* wait operations with timeout /* SYNOPSIS /* #include /* /* int timed_waitpid(pid, statusp, options, time_limit) /* pid_t pid; /* WAIT_STATUS_T *statusp; /* int options; /* int time_limit; /* DESCRIPTION /* \fItimed_waitpid\fR() waits at most \fItime_limit\fR seconds /* for process termination. /* /* Arguments: /* .IP "pid, statusp, options" /* The process ID, status pointer and options passed to waitpid(3). /* .IP time_limit /* The time in seconds that timed_waitpid() will wait. /* This must be a number > 0. /* DIAGNOSTICS /* Panic: interface violation. /* /* When the time limit is exceeded, the result is -1 and errno /* is set to ETIMEDOUT. Otherwise, the result value is the result /* from the underlying waitpid() routine. /* BUGS /* If there were a \fIportable\fR way to select() on process status /* information, these routines would not have to use a steenkeeng /* alarm() timer and signal() handler. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /*--*/ /* System library. */ #include #include #include #include #include /* Utility library. */ #include #include #include /* Application-specific. */ static int timed_wait_expired; /* timed_wait_alarm - timeout handler */ static void timed_wait_alarm(int unused_sig) { /* * WARNING WARNING WARNING. * * This code runs at unpredictable moments, as a signal handler. This code * is here only so that we can break out of waitpid(). Don't put any code * here other than for setting a global flag. */ timed_wait_expired = 1; } /* timed_waitpid - waitpid with time limit */ int timed_waitpid(pid_t pid, WAIT_STATUS_T *statusp, int options, int time_limit) { const char *myname = "timed_waitpid"; struct sigaction action; struct sigaction old_action; int time_left; int wpid; /* * Sanity checks. */ if (time_limit <= 0) msg_panic("%s: bad time limit: %d", myname, time_limit); /* * Set up a timer. */ sigemptyset(&action.sa_mask); action.sa_flags = 0; action.sa_handler = timed_wait_alarm; if (sigaction(SIGALRM, &action, &old_action) < 0) msg_fatal("%s: sigaction(SIGALRM): %m", myname); timed_wait_expired = 0; time_left = alarm(time_limit); /* * Wait for only a limited amount of time. */ if ((wpid = waitpid(pid, statusp, options)) < 0 && timed_wait_expired) errno = ETIMEDOUT; /* * Cleanup. */ alarm(0); if (sigaction(SIGALRM, &old_action, (struct sigaction *) 0) < 0) msg_fatal("%s: sigaction(SIGALRM): %m", myname); if (time_left) alarm(time_left); return (wpid); } then to packages for 5.1 or 5.0.he 2012-03-11Can't use Bourne shell syntax here... (Even in comments, for PKG_PATH.)he 2011-06-21There is no .../5.99 path to use for PKG_PATH, so change it to 5.1 instead.erh 2010-12-27`` -> $()christos 2010-02-05Move the emergancy terminfo database from /root to /rescue.roy 2010-02-04Install a minimal .terminfo and .terminfo.db in /root.roy 2009-08-26netbsd.org -> NetBSD.org for URLs.tsutsui 2009-05-15Clearer wording when nagging about root logins.ad 2009-02-15Add "/pub" to the PKG_PATH lines in the default .cshrc and .profile so theyerh 2008-11-19Sprinkle /usr/X11R7 where relevant. rc.d/x{fs,dm} are left to be done.cube 2008-11-11Fix csh syntax in lastagc 2008-11-10Add commented out example of PKG_PATH to make using binary packagesjoerg 2007-11-24Source /etc/shrc only if it exists. Inspired by PR install/37209.pavel 2006-09-14Factor out common settings from /root/.shrc and /etc/skel/.shrc to apavel 2006-08-31Sync order with src/etc/skel/dot.cshrc, no functional change.hubertf 2005-02-22Use hostname(1) in preference to uname(1) in case /usr isn't mounted.sketch 2005-02-22Revision 1.2 of dot.shrc changed the prompt to use a HOST variable withoutsketch 2004-05-16Consistently use CONFIGFILES & CONFIGLINKS (which enable the 'configinstall'lukem 2003-09-02Now that we have nuked /sys, change the cdpath to contain /usr/src/syscjep 2002-10-10If we are going to point ENV at .shrc, and link this in as /.profile as wellabs 2001-04-01Fix syntax error in r1.5 -- semicolon needed before closing brace on same line.toddpw 2001-03-01Also make hup work in single user; revert dot.cshrc to atatat's version,tv 2001-03-01Use "head -1" as a generic way to snarf the first line of the pid file;tv 2001-03-01Teach the hup alias to deal with sendmail's pid fileatatat 2000-05-14Add RCSid.simonb 2000-05-14Minor change:mycroft 2000-05-06Since src/gnu/usr.sbin is populated add it to the cdpath.frueauf 2000-02-19Make the tset stuff actually set the environment variables again.mycroft 2000-02-19Simplify the tset crap, and do not set $HOME gratuitously.mycroft 2000-02-161.) bring over the second half of David Brownlee's change to dot.login --jwise 2000-02-16Port to [k]sh(1) startup files David Brownlee's improvement fromjwise 2000-02-15Only display the 'use su' message in the non 'su -' case.abs 1999-11-05(Ab?)use some sh(1) features:mycroft 1999-06-15Don't don't don't assume /usr/bin/id is always present. Loses in single user.abs 1999-04-04Avoid using id(1), as this loses when /usr isn't mounted.mycroft 1999-03-30Add hup, ll and x shell functions similar to the aliases in dot.cshrchubertf 1998-01-17Sync PATH with our csh counterpart.thorpej 1998-01-10fix root .cshrc so that it ends prompts with a '#' when invoked by rootperry 1997-12-17fix paths: remove old cruft and add pkg & X11R6mrg 1997-10-28RCSid police. fix pr#4307 from Eric Haszlakiewicz: csh aliases broken with.mrg 1997-02-15cleanup Lite-1 mergemikel 1997-02-15import 4.4BSD-Litemikel 1996-09-30Fix PR/1024: Add /usr/local/{s,}bin to the path and the gnu sources tochristos 1996-05-22don't put bogus info in here.mrg 1994-12-24get dot out of root's path.cgd 1994-03-26The contents of this file are evaluated by root, users without a home dir,jtc 1994-03-24Changed .login (csh) and .profile (sh) to be consistant with each other.jtc 1993-12-12Set 'BLOCKSIZE' variable (a la 4.4) rather than aliasing a bunch of things.mycroft