[Top] [Prev] [Next]

pctl - process control

include "sys.m";
sys:= load Sys Sys->PATH;
pctl: fn(flags: int, movefd: list of ref FD): int;

Description

A newly spawned Limbo process, also known as a thread, shares with its parent process a number of resources and properties, such as file name space, open file descriptors, and current working directory. The pctl function controls this sharing, allowing a process to gain a copy of a resource rather than to share it, to start with a null resource.

The set of processes sharing a property are called a group; for example, the set of processes sharing a name space are called a name space group. Each process is a member of a process group, typically the set of threads functioning as a single program. All the members of a process group may be terminated at once using the killgrp control message in the prog device.

A call to pctl affects the calling process and, indirectly according to flags, any other processes sharing properties with it.

File Descriptor Group

The File Descriptor group is controlled by the following mutually exclusive options:
NEWFD

Place the process in a new file descriptor group. By default, no files will be open for I/O after this pctl. However, any file descriptor passed in the movefd parameter will be preserved across the call.

FORKFD

Place the process in a new file descriptor group containing a copy of the current set of file descriptors. After this call, any changes the process makes to its set of open file descriptors will not be visible to other processes.

Namespace Group

The Namespace group is controlled by the following mutually exclusive options:
NEWNS

Place the process in a new file name space group containing only a root directory, /, made from an attach to root. The current directory is unaffected by this call. No files other than / will be accessible by name after this pctl and bind and mount calls will be necessary to build a new name space.

FORKNS

Place the process in a new file name space group containing a copy of the current name space. After this call, any changes the process makes to its name space, including chdir calls, will not affect other processes.

NEWPGRP

Establish a new process group with a group id equal to that of the pid of the calling process.

Return Value

The return value of pctl is the numerical process id of the calling process, which can be used for example to access its prog files.

Example

pid:= pctl(0,nil);

Note

Programs that run synchronously from the shell share its file name space, so programs like bind and mount and cd can affect the shell's environment. Programs that need a private space should call pctl with the FORKNS option.

See Also

Limbo System Module and sh - command line interface to the Inferno system in Chapter 5



[Top] [Prev] [Next]

infernosupport@lucent.com
Copyright © 1996,Lucent Technologies, Inc. All rights reserved.