jpage@rruxa.UUCP (J Page) (01/12/88)
UNIX Wizards: Anyone on the net have any suggestions, or ideas on how to emulate the 4.2BSD wait3() system call under System V??? If it helps we are on a Pyramid 9810 under OS/x 4.0. Thanks in advance, Jim Page ihnp4!bellcore!rruxe!jpage
gwyn@brl-smoke.ARPA (Doug Gwyn ) (01/12/88)
In article <360@rruxa.UUCP> jpage@rruxa.UUCP (J Page) writes: >UNIX Wizards: Anyone on the net have any suggestions, or ideas on > how to emulate the 4.2BSD wait3() system call under System V??? Basically, you can't, at least not with the current release. > If it helps we are on a Pyramid 9810 under OS/x 4.0. One would think that there would be a way to execute UCB system calls from the ATT environment, but perhaps (for security reasons?) Pyramid hasn't provided one.
perry@phoenix.Princeton.EDU (Kevin R. Perry) (01/13/88)
In article <360@rruxa.UUCP> jpage@rruxa.UUCP (J Page) writes: >UNIX Wizards: Anyone on the net have any suggestions, or ideas on > how to emulate the 4.2BSD wait3() system call under System V??? > > If it helps we are on a Pyramid 9810 under OS/x 4.0. ...And I'd like to know the same thing, only I need to implement wait3() on a Silicon Graphics IRIS. Kevin Perry perry@phoenix.princeton.edu
rml@hpfcdc.UUCP (01/14/88)
> >UNIX Wizards: Anyone on the net have any suggestions, or ideas on > > how to emulate the 4.2BSD wait3() system call under System V??? > > Basically, you can't, at least not with the current release. True, you cannot emulate all the features. The one feature you can emulate, given some assumptions, is the WNOHANG flag. The emulation uses the (incompletely documented) semantics of the SIGCLD signal; when a handler is installed for SIGCLD, if there are any zombie children, a SIGCLD signal is immediately generated. Thus the following untested code more-or-less does the job. It will not work if there are other signal handlers that might be asynchronously doing forks and waits, but that is likely to apply to any use of wait or wait3. It may cause spurious SIGCLD signals if the user has another handler installed for that signal and there are multiple zombies when wait3 is called; a program expecting BSD SIGCHLD semantics probably won't be bothered by this, while one expecting SysV SIGCLD semantics wouldn't want the wait3 emulation. Credit for this idea goes to Dave Korn. If you want, you can emulate the ru_stime and ru_utime fields of the rusage with calls to times() before and after wait(). int caught_sig; catch_sigcld() { caught_sig = 1; } int wait3 (status, flags, rusage) int *status, flags; void *rusage; /* can't really emulate this */ { int (*oldhandler)(); int return_val; if (rusage != 0) /* probably an error */ if (flags & WNOHANG) { caught_sig = 0; oldhandler = signal (SIGCLD, catch_sigcld); } if (!(flags & WNOHANG) || caught_sig) return_val = wait (status); else return_val = 0; if (flags & WNOHANG) (void) signal (SIGCLD, oldhandler); return (return_val); } Bob Lenk {ihnp4, hplabs}!hpfcla!rml
romain@pyrnj.uucp (Romain Kang) (01/14/88)
In article <360@rruxa.UUCP> jpage@rruxa.UUCP (J Page) writes: | UNIX Wizards: Anyone on the net have any suggestions, or ideas on | how to emulate the 4.2BSD wait3() system call under System V??? | | If it helps we are on a Pyramid 9810 under OS/x 4.0. Pyramid is a special case because the wait3() call is available from the kernel if you give the right syscall number, regardless of whether your program is in the UCB or ATT universe. You could punt and link UCB wait3.o with your ATT binary. In System V make, you can grab wait3() with wait3.o: /.ucblib/libc.a(wait3.o) ar x /.ucblib/libc.a wait3.o This is completely nonportable, of course. -- Romain Kang {allegra,cmcl2,pyramid,rutgers}!pyrnj!romain Pyramid Technology Corp. / 10 Woodbridge Center Dr. / Woodbridge, NJ 07095
news@jpusa1.UUCP (usenet) (01/15/88)
In article <7060@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: -In article <360@rruxa.UUCP> jpage@rruxa.UUCP (J Page) writes: ->UNIX Wizards: Anyone on the net have any suggestions, or ideas on -> how to emulate the 4.2BSD wait3() system call under System V??? - -Basically, you can't, at least not with the current release. - It depends on what you're trying to do. If all you need is a nonblocking wait you can do something like: noop(){;} nonblockingwait() { int i, w; int (*oldsig)() = signal(SIGALRM, noop); int oldalrm = alarm(1); i = wait(&w); alarm(0); signal(SIGALRM, oldsig); alarm(oldalrm); ... } -- Stu Heiss {gargoyle,ihnp4}!jpusa1!stu