[Top] [Prev] [Next] [Bottom]


[Contents] [Index]

pctl - process control

pctl: fn(flags: int, movefd: list of int): int;
## returns process id (pid) of the calling process.

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 namespace, 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 namespace are called a namespace 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

When you use the NEWFD flag, all file descriptors are closed except those passed in the movefd parameter.

FORKFD

When you use the FORKFD flag, all open file descriptors are duplicated in the new file descriptor group. The list of file descriptors contained in movefd will be closed in the old group.

namespace group

The namespace group is controlled by the following mutually exclusive options:

NEWNS

Place the process in a new file namespace 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 namespace.

FORKNS

Place the process in a new file namespace group containing a copy of the current namespace. After this call, any changes the process makes to its namespace, 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.

NODEVS

Place the process in a new file namespace group that blocks access to the file trees implemented by a kernel device driver (e.g., #I, #s, #d).

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

This example assigns the integer value of the caller's pid to the variable mypid.

mypid := pctl(0,nil);

Note

Programs that run synchronously from the shell share its file namespace, 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

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


[Top] [Prev] [Next] [Bottom]

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