From b6d5c413407e357001df80e81ab6b7ff64c66a99 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 23 Feb 1996 19:56:55 +0000 Subject: rfork/minherit glue in libc man pages adapted from OpenBSD's versions. --- lib/libc/i386/sys/rfork.S | 51 +++++++++++++++++++++ lib/libc/sys/Makefile.inc | 14 +++--- lib/libc/sys/minherit.2 | 67 +++++++++++++++++++++++++++ lib/libc/sys/rfork.2 | 112 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 237 insertions(+), 7 deletions(-) create mode 100644 lib/libc/i386/sys/rfork.S create mode 100644 lib/libc/sys/minherit.2 create mode 100644 lib/libc/sys/rfork.2 (limited to 'lib') diff --git a/lib/libc/i386/sys/rfork.S b/lib/libc/i386/sys/rfork.S new file mode 100644 index 0000000..189d399 --- /dev/null +++ b/lib/libc/i386/sys/rfork.S @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#if defined(SYSLIBC_RCS) && !defined(lint) + .text + .asciz "$Id$" +#endif /* SYSLIBC_RCS and not lint */ + +#include "SYS.h" + +PSYSCALL(rfork) + cmpl $0,%edx /* parent, since %edx == 0 in parent, 1 in child */ + je 1f + movl $0,%eax +1: + ret /* pid = rfork(); */ diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index f115d3d..44534cd 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -5,7 +5,7 @@ # modules with non-default implementations on at least one architecture: SRCS+= Ovfork.S brk.S cerror.S exect.S fork.S pipe.S ptrace.S reboot.S \ - sbrk.S setlogin.S sigpending.S sigprocmask.S sigreturn.S \ + rfork.S sbrk.S setlogin.S sigpending.S sigprocmask.S sigreturn.S \ sigsuspend.S syscall.S # glue to provide compatibility between GCC 1.X and 2.X @@ -21,11 +21,13 @@ ASM= accept.o access.o acct.o adjtime.o bind.o chdir.o chflags.o chmod.o \ getrlimit.o getrusage.o getsockname.o getsockopt.o gettimeofday.o \ getuid.o ioctl.o kill.o ktrace.o lfs_bmapv.o lfs_markv.o \ lfs_segclean.o lfs_segwait.o link.o listen.o lstat.o \ - madvise.o mincore.o mkdir.o mkfifo.o mknod.o mlock.o mount.o \ + madvise.o mincore.o minherit.o mkdir.o mkfifo.o mknod.o mlock.o \ + mount.o \ mprotect.o msgsys.o msync.o munlock.o munmap.o nfssvc.o \ ntp_adjtime.o open.o pathconf.o profil.o quotactl.o read.o \ readlink.o readv.o recvfrom.o recvmsg.o rename.o revoke.o rmdir.o \ - rtprio.o select.o semsys.o sendmsg.o sendto.o setegid.o seteuid.o setgid.o \ + rtprio.o select.o semsys.o sendmsg.o sendto.o setegid.o seteuid.o \ + setgid.o \ setgroups.o setitimer.o setpgid.o setpriority.o \ setregid.o setreuid.o setrlimit.o \ setsid.o setsockopt.o settimeofday.o setuid.o shmsys.o shutdown.o \ @@ -93,8 +95,8 @@ MAN2+= sys/accept.2 sys/access.2 sys/acct.2 sys/adjtime.2 sys/bind.2 \ sys/mmap.2 sys/mount.2 sys/mprotect.2 sys/msync.2 sys/munmap.2 \ sys/ptrace.2 sys/nfssvc.2 sys/open.2 sys/pathconf.2 sys/pipe.2 \ sys/profil.2 sys/quotactl.2 sys/read.2 sys/readlink.2 sys/reboot.2 \ - sys/recv.2 sys/rename.2 sys/revoke.2 sys/rmdir.2 sys/rtprio.2 \ - sys/select.2 \ + sys/recv.2 sys/rename.2 sys/revoke.2 sys/rfork.2 sys/rmdir.2 \ + sys/rtprio.2 sys/select.2 \ sys/semctl.2 sys/semget.2 sys/semop.2 \ sys/send.2 sys/setgroups.2 \ sys/setpgid.2 sys/setregid.2 sys/setreuid.2 \ @@ -106,8 +108,6 @@ MAN2+= sys/accept.2 sys/access.2 sys/acct.2 sys/adjtime.2 sys/bind.2 \ sys/sync.2 sys/syscall.2 sys/truncate.2 sys/umask.2 sys/unlink.2 \ sys/utimes.2 sys/vfork.2 sys/wait.2 sys/write.2 -# missing: ptrace.2 - MLINKS+=brk.2 sbrk.2 MLINKS+=dup.2 dup2.2 MLINKS+=chdir.2 fchdir.2 diff --git a/lib/libc/sys/minherit.2 b/lib/libc/sys/minherit.2 new file mode 100644 index 0000000..cc26fa6 --- /dev/null +++ b/lib/libc/sys/minherit.2 @@ -0,0 +1,67 @@ +.\" $Id$ +.\" +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)minherit.2 8.1 (Berkeley) 6/9/93 +.\" +.Dd Feb 17, 1996 +.Dt MINHERIT 2 +.Os +.Sh NAME +.Nm minherit +.Nd control the inheritance of pages +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn minherit "caddr_t addr" "size_t len" "int inherit" +.Sh DESCRIPTION +The +.Fn minherit +system call +changes the specified pages to have the inheritance characteristic +.Fa inherit . +Not all implementations will guarantee that the inheritance characteristic +can be set on a page basis; +the granularity of changes may be as large as an entire region. +.Sh SEE ALSO +.Xr fork 2 , +.Xr madvise 2 , +.Xr mincore 2 , +.Xr mprotect 2 , +.Xr msync 2 , +.Xr munmap 2 , +.Xr rfork 2 +.Sh HISTORY +The +.Fn minherit +function first appeared in OpenBSD. diff --git a/lib/libc/sys/rfork.2 b/lib/libc/sys/rfork.2 new file mode 100644 index 0000000..6158f51 --- /dev/null +++ b/lib/libc/sys/rfork.2 @@ -0,0 +1,112 @@ +.\" +.\" This manual page is taken directly from Plan9, and modified to +.\" describe the actual BSD implementation. Permission for +.\" use of this page comes from Rob Pike . +.\" +.Dd Jan 12, 1996 +.Dt RFORK 2 +.Os +.Sh NAME +.Nm rfork +.Nd manipulate process resources +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn rfork "int flags" +.Sh DESCRIPTION +Forking, vforking or rforking is the only way new processes are created. +The +.Fa flags +argument to +.Fn rfork +selects which resources of the +invoking process (parent) are shared +by the new process (child) or initialized to +their default values. +The resources include +the open file descriptor table (which, when shared, permits processes +to open and close files for other processes), +and open files. +.Fa Flags +is the logical OR of some subset of +.Bl -tag -width "RFCNAMEG" -compact -offset indent +.It RFPROC +If set a new process is created; otherwise changes affect the +current process. +The current implementation requires this flag to always be set. +.It RFNOWAIT +If set, the child process will be dissociated from the parent. Upon +exit the child will not leave a status for the parent to collect. +See +.Xr wait 2 . +This is not currently implemented. +.It RFNAMEG, RFCNAMEG, RFENVG, RFCENVG, RFNOTEG +These are Plan 9 specific flags, and not implemented. +.It RFFDG +If set, the invoker's file descriptor table (see +.Xr intro 2 +) is copied; otherwise the two processes share a +single table. +.It RFCFDG +If set, the new process starts with a clean file descriptor table. +Is mutually exclusive with +.Dv RFFDG . +.It RFMEM +If set, the kernel will force sharing of the entire address space. +The child +will then inherit all the shared segments the parent process owns. Other segment +types will be unaffected. Subsequent forks by the parent will then +propagate the shared data and bss between children. The stack segment +is always split. May be set only with +.Dv RFPROC . +.El +.Pp +File descriptors in a shared file descriptor table are kept +open until either they are explicitly closed +or all processes sharing the table exit. +.Pp +If +.Dv RFPROC +is set, the +value returned in the parent process +is the process id +of the child process; the value returned in the child is zero. +Without +.Dv RFPROC , +the return value is zero. +Process id's range from 1 to the maximum integer +.Ft ( int ) +value. +.Fn Rfork +will sleep, if necessary, until required process resources are available. +.Pp +.Fn Fork +can be implemented as a call to +.Xr rfork "RFFDG|RFPROC" +but isn't for backwards compatibility. +.Sh ERRORS +.Fn Rfork +will fail and no child process will be created if: +.Bl -tag -width Er +.It Bq Er EAGAIN +The system-imposed limit on the total +number of processes under execution would be exceeded. +This limit is configuration-dependent. +.It Bq Er EAGAIN +The system-imposed limit +.Dv MAXUPRC +.Pq Aq Pa sys/param.h +on the total number of +processes under execution by a single user would be exceeded. +.It Bq Er ENOMEM +There is insufficient swap space for the new process. +.El +.Sh SEE ALSO +.Xr intro 2 , +.Xr fork 2 , +.Xr vfork 2 , +.Xr minherit 2 +.Sh HISTORY +The +.Fn rfork +function first appeared in Plan9. -- cgit v1.1