Chapter 31. System Interaction

alarm expr

Schedules a SIGALRM signal to be delivered after expr seconds. If expr is zero, cancels a pending timer.

chdir [ expr ]

Changes the working directory. Uses $ENV{HOME} or $ENV{LOGNAME} if expr is omitted.

chroot filename†

Changes the root directory for the process and any future children.

die [ list ]

Prints the value of list to STDERR and exits with value $! || ($? >> 8) || 255. list defaults to Died.

Inside an eval, the error message is stuffed into $@, and the eval is terminated returning undef ; this makes die the way to raise an exception.

exec [ program ] list

Executes the system command in list; does not return. program can be used to explictly designate the program to execute the command.

exit [ expr ]

Exits immediately with the value of expr, which defaults to zero. Calls END routines and object destructors before exiting.

fork

Does a fork syscall. Returns the process id of the child to the parent process (or undef on failure) and zero to the child process.

getlogin

Returns the current login name as known by the system. If it returns false, use getpwuid.

getpgrp [ pid ]

Returns the process group for process pid. If pid is zero, or omitted, uses the current process.

getppid

Returns the process id of the parent process.

getpriority which, who

Returns the current priority for a process, process group, or user. Use getpriority 0,0 to designate the current process.

glob expr

Returns a list of filenames that match the C-shell pattern(s) in expr. Use File::Glob for more detailed globbing control.

kill list

Sends a signal to a list of processes. The first element of the list must be the signal to send, either numerically (e.g., 1), or its name as a string (e.g., HUP). Negative signals affect process groups instead of processes.

setpgrp pid, pgrp

Sets the process group for the pid. If pid is zero, affects the current process.

setpriority which, who, priority

Sets the current priority for a process, process group, or a user.

sleep [ expr ]

Causes the program to sleep for expr seconds, or forever if expr is omitted. Returns the number of seconds actually slept.

syscall list

Calls the syscall specified in the first element of the list, passing the rest of the list as arguments to the call. Returns −1 (and sets $!) on error.

system [ program ] list

Like exec, except that a fork is performed first, and the parent process waits for the child process to complete. During the wait, the signals SIGINT and SIGQUIT are passed to the child process.

Returns the exit status of the child process. Zero indicates success, not failure.

program can be used to explicitly designate the program to execute the command.

times

Returns a four-element list (user, system, cuser, csystem) giving the user and system times, in seconds, for this process and the children of this process.

umask [ expr ]

Sets the umask for the process and returns the old one. If expr is a number, it must be an octal number. If expr is omitted, umask does not change the current umask value.

wait

Waits for a child process to terminate and returns the process id of the deceased process (−1 if none). The status is returned in $?.

waitpid pid, flags

Performs the same function as the corresponding syscall. Returns 1 when process pid is dead, −1 if nonexistent.

warn [ list ]

Prints the list on STDERR like die, but doesn’t exit. list defaults to Warning: something's wrong.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset