Next: , Previous: , Up: Packages   [Contents][Index]

5.7 Posix Extensions

If 'posix is provided (by linking in posix.o), the following functions are defined:

Function: open-pipe string modes

If the string modes contains an r, returns an input port capable of delivering characters from the standard output of the system command string. Otherwise, returns an output port capable of receiving characters which become the standard input of the system command string. If a pipe cannot be created #f is returned.

Function: open-input-pipe string

Returns an input port capable of delivering characters from the standard output of the system command string. If a pipe cannot be created #f is returned.

Function: open-output-pipe string

Returns an output port capable of receiving characters which become the standard input of the system command string. If a pipe cannot be created #f is returned.

Function: broken-pipe port

If this function is defined at top level, it will be called when an output pipe is closed from the other side (this is the condition under which a SIGPIPE is sent). The already closed port will be passed so that any necessary cleanup may be done. An error is not signaled when output to a pipe fails in this way, but any further output to the closed pipe will cause an error to be signaled.

Function: close-port pipe

Closes the pipe, rendering it incapable of delivering or accepting characters. This routine has no effect if the pipe has already been closed. The value returned is unspecified.

Function: pipe

Returns (cons rd wd) where rd and wd are the read and write (port) ends of a pipe respectively.

Function: fork

Creates a copy of the process calling fork. Both processes return from fork, but the calling (parent) process’s fork returns the child process’s ID whereas the child process’s fork returns 0.

For a discussion of IDs See Process Persona in libc.

Function: getppid

Returns the process ID of the parent of the current process. For a process’s own ID See getpid.

Function: getuid

Returns the real user ID of this process.

Function: getgid

Returns the real group ID of this process.

Function: getegid

Returns the effective group ID of this process.

Function: geteuid

Returns the effective user ID of this process.

Function: setuid id

Sets the real user ID of this process to id. Returns #t if successful, #f if not.

Function: setgid id

Sets the real group ID of this process to id. Returns #t if successful, #f if not.

Function: setegid id

Sets the effective group ID of this process to id. Returns #t if successful, #f if not.

Function: seteuid id

Sets the effective user ID of this process to id. Returns #t if successful, #f if not.

Function: kill pid sig

The kill function sends the signal signum to the process or process group specified by pid. Besides the signals listed in Standard Signals in GNU C Library, signum can also have a value of zero to check the validity of the pid.

The pid specifies the process or process group to receive the signal:

> 0

The process whose identifier is pid.

0

All processes in the same process group as the sender. The sender itself does not receive the signal.

-1

If the process is privileged, send the signal to all processes except for some special system processes. Otherwise, send the signal to all processes with the same effective user ID.

< -1

The process group whose identifier is (abs pid).

A process can send a signal to itself with (kill (getpid) signum). If kill is used by a process to send a signal to itself, and the signal is not blocked, then kill delivers at least one signal (which might be some other pending unblocked signal instead of the signal signum) to that process before it returns.

The return value from kill is zero if the signal can be sent successfully. Otherwise, no signal is sent, and a value of -1 is returned. If pid specifies sending a signal to several processes, kill succeeds if it can send the signal to at least one of them. There’s no way you can tell which of the processes got the signal or whether all of them did.

Function: waitpid pid options

The waitpid function suspends execution of the current process until a child as specified by the pid argument has exited, or until a signal is delivered whose action is to terminate the current process or to call a signal handling function. If a child as requested by pid has already exited by the time of the call (a so-called zombie process), the function returns immediately. Any system resources used by the child are freed.

The value of pid can be:

< -1

which means to wait for any child process whose process group ID is equal to the absolute value of pid.

-1

which means to wait for any child process; this is the same behaviour which wait exhibits.

0

which means to wait for any child process whose process group ID is equal to that of the calling process.

> 0

which means to wait for the child whose process ID is equal to the value of pid.

The value of options is one of the following:

  1. Nothing special.
  2. (WNOHANG) which means to return immediately if no child is there to be waited for.
  3. (WUNTRACED) which means to also return for children which are stopped, and whose status has not been reported.
  4. Which means both of the above.

The return value normally is the exit status of the child process, including the exit value along with flags indicating whether a coredump was generated or the child terminated as a result of a signal. If the WNOHANG option was specified and no child process is waiting to be noticed, the value is zero. A value of #f is returned in case of error and errno is set. For information about the errno codes See Process Completion in libc.

Function: uname

You can use the uname procedure to find out some information about the type of computer your program is running on.

Returns a vector of strings. These strings are:

  1. The name of the operating system in use.
  2. The network name of this particular computer.
  3. The current release level of the operating system implementation.
  4. The current version level within the release of the operating system.
  5. Description of the type of hardware that is in use.

    Some examples are ‘"i386-ANYTHING"’, ‘"m68k-hp"’, ‘"sparc-sun"’, ‘"m68k-sun"’, ‘"m68k-sony"’ and ‘"mips-dec"’.

Function: getpw name
Function: getpw uid
Function: getpw

Returns a vector of information for the entry for NAME, UID, or the next entry if no argument is given. The information is:

  1. The user’s login name.
  2. The encrypted password string.
  3. The user ID number.
  4. The user’s default group ID number.
  5. A string typically containing the user’s real name, and possibly other information such as a phone number.
  6. The user’s home directory, initial working directory, or #f, in which case the interpretation is system-dependent.
  7. The user’s default shell, the initial program run when the user logs in, or #f, indicating that the system default should be used.
Function: setpwent #t

Rewinds the pw entry table back to the begining.

Function: setpwent #f
Function: setpwent

Closes the pw table.

Function: getgr name
Function: getgr uid
Function: getgr

Returns a vector of information for the entry for NAME, UID, or the next entry if no argument is given. The information is:

  1. The name of the group.
  2. The encrypted password string.
  3. The group ID number.
  4. A list of (string) names of users in the group.
Function: setgrent #t

Rewinds the group entry table back to the begining.

Function: setgrent #f
Function: setgrent

Closes the group table.

Function: getgroups

Returns a vector of all the supplementary group IDs of the process.

The link function makes a new link to the existing file named by oldname, under the new name newname.

link returns a value of #t if it is successful and #f on failure.

Function: chown filename owner group

The chown function changes the owner of the file filename to owner, and its group owner to group.

chown returns a value of #t if it is successful and #f on failure.

Function: ttyname port

If port port is associated with a terminal device, returns a string containing the file name of termainal device; otherwise #f.


Next: , Previous: , Up: Packages   [Contents][Index]