setpgrp on System V
Brandon S. Allbery
allbery at ncoast.ORG
Fri May 26 09:11:03 AEST 1989
As quoted from <1127 at altos86.UUCP> by clp at altos86.UUCP (Chuck L. Peterson):
+---------------
| The library calls setpgrp and getpgrp both use the setpgrp() system call.
| Setgrp() gets translated to setgrp(1), and getpgrp gets translated to
| setpgrp(0). The manuals are consistent with the library call and
| say that setpgrp takes no argument. Are there any other cases where
| the C library changes arguments to system calls? This seems odd.
+---------------
Historically, yes. Consider that system calls are designed to be called at
the level of assembler, not C. An example (this may or may not be true any
more, but I'm betting that it is): fork() used to be (still is?) used in
the following way:
movl %d0,#SC_FORK ; number for fork syscall
trap ; trap to kernel
jmp parent ; I may have these two swapped
jmp child
That is, the newly created process starts executing one "JMP" instruction
away from the original process. Weird.
Some systems treat u-area get/set functions as aspects of a single system
call. I don't know if any of the major Unixes do this. (Example: getpid()
becomes getset(GS_GET, GS_PID, 0).)
The signal() system call linkage in C is sometimes (always?) a wrapper for
the *real* signal syscall; the kernel doesn't build a C stack frame when it
traps the signal, so signal() saves the C function address in an array and
sets the signal trap for an internal routine (in assembler) which builds a C
stack frame and then calls the C trap routine, then breaks down the stack
frame and does a "return from interrupt". (I discovered this after the n'th
time that a program wouldn't link because "_sigtrap" was multiply defined
under Plexus System III.)
++Brandon
--
Brandon S. Allbery, moderator of comp.sources.misc allbery at ncoast.org
uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery at hal.cwru.edu
Send comp.sources.misc submissions to comp-sources-misc@<backbone>
NCoast Public Access UN*X - (216) 781-6201, 300/1200/2400 baud, login: makeuser
More information about the Comp.unix.wizards
mailing list