Defines | Functions

syscalls.cc File Reference

#include <cstdio>
#include <cstring>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include "file-ops.h"
#include "file-stat.h"
#include "oct-env.h"
#include "oct-syscalls.h"
#include "oct-uname.h"
#include "defun.h"
#include "error.h"
#include "gripes.h"
#include "lo-utils.h"
#include "oct-map.h"
#include "oct-obj.h"
#include "oct-stdstrm.h"
#include "oct-stream.h"
#include "sysdep.h"
#include "utils.h"
#include "variables.h"
#include "input.h"
Include dependency graph for syscalls.cc:

Go to the source code of this file.

Defines

#define WCONTINUE   0
#define WNOHANG   0
#define WUNTRACED   0

Functions

static octave_value const_value (const octave_value_list &args, int val)
 DEFUN (gethostname, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} gethostname ()\n\ Return the hostname of the system where Octave is running.\n\ @end deftypefn")
 DEFUN (uname, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{uts}, @var{err}, @var{msg}] =} uname ()\n\ Return system information in the structure. For example:\n\ \n\ @example\n\ @group\n\ uname ()\n\ @result{} @{\n\ sysname = x86_64\n\ nodename = segfault\n\ release = 2.6.15-1-amd64-k8-smp\n\ version = Linux\n\ machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006\n\ @}\n\ @end group\n\ @end example\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ @end deftypefn")
 DEFUNX ("WNOHANG", FWNOHANG, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WNOHANG ()\n\ Return the numerical value of the option argument that may be\n\ passed to @code{waitpid} to indicate that it should return its\n\ status immediately instead of waiting for a process to exit.\n\ @seealso{waitpid, WUNTRACED, WCONTINUE}\n\ @end deftypefn")
 DEFUNX ("O_WRONLY", FO_WRONLY, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} O_WRONLY ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate that a file is open for\n\ writing only.\n\ @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC}\n\ @end deftypefn")
 DEFUNX ("O_TRUNC", FO_TRUNC, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} O_TRUNC ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate that if file exists, it should\n\ be truncated when writing.\n\ @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_WRONLY}\n\ @end deftypefn")
 DEFUNX ("O_SYNC", FO_SYNC, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} O_SYNC ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate that a file is open for\n\ synchronous I/O.\n\ @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}\n\ @end deftypefn")
 DEFUNX ("O_RDWR", FO_RDWR, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} O_RDWR ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate that a file is open for both\n\ reading and writing.\n\ @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_SYNC, O_TRUNC, O_WRONLY}\n\ @end deftypefn")
 DEFUNX ("O_RDONLY", FO_RDONLY, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} O_RDONLY ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate that a file is open for\n\ reading only.\n\ @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ @end deftypefn")
 DEFUNX ("O_NONBLOCK", FO_NONBLOCK, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} O_NONBLOCK ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate that non-blocking I/O is in use,\n\ or that may be passsed to @code{fcntl} to set non-blocking I/O.\n\ @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ @end deftypefn")
 DEFUNX ("O_EXCL", FO_EXCL, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} O_EXCL ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate that file locking is used.\n\ @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ @end deftypefn")
 DEFUNX ("WCONTINUE", FWCONTINUE, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WCONTINUE ()\n\ Return the numerical value of the option argument that may be\n\ passed to @code{waitpid} to indicate that it should also return\n\ if a stopped child has been resumed by delivery of a @code{SIGCONT}\n\ signal.\n\ @seealso{waitpid, WNOHANG, WUNTRACED}\n\ @end deftypefn")
 DEFUNX ("O_ASYNC", FO_ASYNC, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} O_ASYNC ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate asynchronous I/O.\n\ @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ @end deftypefn")
 DEFUNX ("O_APPEND", FO_APPEND, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} O_APPEND ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate each write operation appends,\n\ or that may be passed to @code{fcntl} to set the write mode to append.\n\ @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ @end deftypefn")
 DEFUNX ("F_SETFL", FF_SETFL, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} F_SETFL ()\n\ Return the numerical value to pass to @code{fcntl} to set the file\n\ status flags.\n\ @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFD}\n\ @end deftypefn")
 DEFUNX ("F_SETFD", FF_SETFD, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} F_SETFD ()\n\ Return the numerical value to pass to @code{fcntl} to set the file\n\ descriptor flags.\n\ @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFL}\n\ @end deftypefn")
 DEFUNX ("F_GETFL", FF_GETFL, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} F_GETFL ()\n\ Return the numerical value to pass to @code{fcntl} to return the\n\ file status flags.\n\ @seealso{fcntl, F_DUPFD, F_GETFD, F_SETFD, F_SETFL}\n\ @end deftypefn")
 DEFUNX ("F_GETFD", FF_GETFD, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} F_GETFD ()\n\ Return the numerical value to pass to @code{fcntl} to return the\n\ file descriptor flags.\n\ @seealso{fcntl, F_DUPFD, F_GETFL, F_SETFD, F_SETFL}\n\ @end deftypefn")
 DEFUNX ("F_DUPFD", FF_DUPFD, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} F_DUPFD ()\n\ Return the numerical value to pass to @code{fcntl} to return a\n\ duplicate file descriptor.\n\ @seealso{fcntl, F_GETFD, F_GETFL, F_SETFD, F_SETFL}\n\ @end deftypefn")
 DEFUNX ("S_ISREG", FS_ISREG, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISREG (@var{mode})\n\ Return true if @var{mode} corresponds to a regular file. The value\n\ of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn")
 DEFUNX ("canonicalize_file_name", Fcanonicalize_file_name, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{cname}, @var{status}, @var{msg}]} canonicalize_file_name (@var{name})\n\ Return the canonical name of file @var{name}.\n\ @end deftypefn")
 DEFUNX ("WIFCONTINUED", FWIFCONTINUED, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WIFCONTINUED (@var{status})\n\ Given @var{status} from a call to @code{waitpid}, return true if the\n\ child process was resumed by delivery of @code{SIGCONT}.\n\ @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG}\n\ @end deftypefn")
 DEFUNX ("WSTOPSIG", FWSTOPSIG, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WSTOPSIG (@var{status})\n\ Given @var{status} from a call to @code{waitpid}, return the number of\n\ the signal which caused the child to stop. This function should only\n\ be employed if @code{WIFSTOPPED} returned true.\n\ @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WIFCONTINUED}\n\ @end deftypefn")
 DEFUNX ("WIFSTOPPED", FWIFSTOPPED, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WIFSTOPPED (@var{status})\n\ Given @var{status} from a call to @code{waitpid}, return true if the\n\ child process was stopped by delivery of a signal; this is only\n\ possible if the call was done using @code{WUNTRACED} or when the child\n\ is being traced (see ptrace(2)).\n\ @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WSTOPSIG, WIFCONTINUED}\n\ @end deftypefn")
 DEFUNX ("WCOREDUMP", FWCOREDUMP, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WCOREDUMP (@var{status})\n\ Given @var{status} from a call to @code{waitpid}, return true if the\n\ child produced a core dump. This function should only be employed if\n\ @code{WIFSIGNALED} returned true. The macro used to implement this\n\ function is not specified in POSIX.1-2001 and is not available on some\n\ Unix implementations (e.g., AIX, SunOS).\n\ @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ @end deftypefn")
 DEFUNX ("WTERMSIG", FWTERMSIG, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WTERMSIG (@var{status})\n\ Given @var{status} from a call to @code{waitpid}, return the number of\n\ the signal that caused the child process to terminate. This function\n\ should only be employed if @code{WIFSIGNALED} returned true.\n\ @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ @end deftypefn")
 DEFUNX ("getpgrp", Fgetpgrp, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {pgid =} getpgrp ()\n\ Return the process group id of the current process.\n\ @end deftypefn")
 DEFUNX ("lstat", Flstat, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{symlink})\n\ Return a structure @var{info} containing information about the symbolic link\n\ @var{symlink}. The function outputs are described in the documentation for\n\ @code{stat}.\n\ @seealso{stat}\n\ @end deftypefn")
 DEFUNX ("WIFEXITED", FWIFEXITED, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WIFEXITED (@var{status})\n\ Given @var{status} from a call to @code{waitpid}, return true if the\n\ child terminated normally.\n\ @seealso{waitpid, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ @end deftypefn")
 DEFUNX ("waitpid", Fwaitpid, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{pid}, @var{status}, @var{msg}] =} waitpid (@var{pid}, @var{options})\n\ Wait for process @var{pid} to terminate. The @var{pid} argument can be:\n\ \n\ @table @asis\n\ @item @minus{}1\n\ Wait for any child process.\n\ \n\ @item 0\n\ Wait for any child process whose process group ID is equal to that of\n\ the Octave interpreter process.\n\ \n\ @item > 0\n\ Wait for termination of the child process with ID @var{pid}.\n\ @end table\n\ \n\ The @var{options} argument can be a bitwise OR of zero or more of\n\ the following constants:\n\ \n\ @table @code\n\ @item 0\n\ Wait until signal is received or a child process exits (this is the\n\ default if the @var{options} argument is missing).\n\ \n\ @item WNOHANG\n\ Do not hang if status is not immediately available.\n\ \n\ @item WUNTRACED\n\ Report the status of any child processes that are stopped, and whose\n\ status has not yet been reported since they stopped.\n\ \n\ @item WCONTINUE\n\ Return if a stopped child has been resumed by delivery of @code{SIGCONT}.\n\ This value may not be meaningful on all systems.\n\ @end table\n\ \n\ If the returned value of @var{pid} is greater than 0, it is the process\n\ ID of the child process that exited. If an error occurs, @var{pid} will\n\ be less than zero and @var{msg} will contain a system-dependent error\n\ message. The value of @var{status} contains additional system-dependent\n\ information about the subprocess that exited.\n\ @seealso{WCONTINUE, WCOREDUMP, WEXITSTATUS, WIFCONTINUED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED}\n\ @end deftypefn")
 DEFUNX ("unlink", Funlink, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} unlink (@var{file})\n\ Delete the file named @var{file}.\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ @end deftypefn")
 DEFUNX ("getuid", Fgetuid, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {uid =} getuid ()\n\ Return the real user id of the current process.\n\ @end deftypefn")
 DEFUNX ("geteuid", Fgeteuid, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {euid =} geteuid ()\n\ Return the effective user id of the current process.\n\ @end deftypefn")
 DEFUNX ("S_ISSOCK", FS_ISSOCK, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISSOCK (@var{mode})\n\ Return true if @var{mode} corresponds to a socket. The value\n\ of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn")
 DEFUNX ("S_ISLNK", FS_ISLNK, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISLNK (@var{mode})\n\ Return true if @var{mode} corresponds to a symbolic link. The value\n\ of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn")
 DEFUNX ("O_CREAT", FO_CREAT, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} O_CREAT ()\n\ Return the numerical value of the file status flag that may be\n\ returned by @code{fcntl} to indicate that a file should be\n\ created if it does not exist.\n\ @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ @end deftypefn")
 DEFUNX ("S_ISBLK", FS_ISBLK, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISBLK (@var{mode})\n\ Return true if @var{mode} corresponds to a block device. The value\n\ of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn")
 DEFUNX ("S_ISCHR", FS_ISCHR, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISCHR (@var{mode})\n\ Return true if @var{mode} corresponds to a character device. The value\n\ of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn")
 DEFUNX ("S_ISDIR", FS_ISDIR, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISDIR (@var{mode})\n\ Return true if @var{mode} corresponds to a directory. The value\n\ of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn")
 DEFUNX ("getppid", Fgetppid, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {pid =} getppid ()\n\ Return the process id of the parent process.\n\ @end deftypefn")
 DEFUNX ("stat", Fstat, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{file})\n\ @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{fid})\n\ @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{file})\n\ @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{fid})\n\ Return a structure @var{info} containing the following information about\n\ @var{file} or file identifier @var{fid}.\n\ \n\ @table @code\n\ @item dev\n\ ID of device containing a directory entry for this file.\n\ \n\ @item ino\n\ File number of the file.\n\ \n\ @item mode\n\ File mode, as an integer. Use the functions @w{@code{S_ISREG}},\n\ @w{@code{S_ISDIR}}, @w{@code{S_ISCHR}}, @w{@code{S_ISBLK}}, @w{@code{S_ISFIFO}},\n\ @w{@code{S_ISLNK}}, or @w{@code{S_ISSOCK}} to extract information from this\n\ value.\n\ \n\ @item modestr\n\ File mode, as a string of ten letters or dashes as would be returned by\n\ @kbd{ls -l}.\n\ \n\ @item nlink\n\ Number of links.\n\ \n\ @item uid\n\ User ID of file's owner.\n\ \n\ @item gid\n\ Group ID of file's group.\n\ \n\ @item rdev\n\ ID of device for block or character special files.\n\ \n\ @item size\n\ Size in bytes.\n\ \n\ @item atime\n\ Time of last access in the same form as time values returned from\n\ @code{time}. @xref{Timing Utilities}.\n\ \n\ @item mtime\n\ Time of last modification in the same form as time values returned from\n\ @code{time}. @xref{Timing Utilities}.\n\ \n\ @item ctime\n\ Time of last file status change in the same form as time values\n\ returned from @code{time}. @xref{Timing Utilities}.\n\ \n\ @item blksize\n\ Size of blocks in the file.\n\ \n\ @item blocks\n\ Number of blocks allocated for file.\n\ @end table\n\ \n\ If the call is successful @var{err} is 0 and @var{msg} is an empty\n\ string. If the file does not exist, or some other error occurs, @var{s}\n\ is an empty matrix, @var{err} is @minus{}1, and @var{msg} contains the\n\ corresponding system error message.\n\ \n\ If @var{file} is a symbolic link, @code{stat} will return information\n\ about the actual file that is referenced by the link. Use @code{lstat}\n\ if you want information about the symbolic link itself.\n\ \n\ For example:\n\ \n\ @example\n\ [s, err, msg] = stat (\"/vmlinuz\")\n\ @result{} s =\n\ @{\n\ atime = 855399756\n\ rdev = 0\n\ ctime = 847219094\n\ uid = 0\n\ size = 389218\n\ blksize = 4096\n\ mtime = 847219094\n\ gid = 6\n\ nlink = 1\n\ blocks = 768\n\ mode = -rw-r--r--\n\ modestr = -rw-r--r--\n\ ino = 9316\n\ dev = 2049\n\ @}\n\ @result{} err = 0\n\ @result{} msg =\n\ @end example\n\ @end deftypefn")
 DEFUNX ("pipe", Fpipe, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{read_fd}, @var{write_fd}, @var{err}, @var{msg}] =} pipe ()\n\ Create a pipe and return the reading and writing ends of the pipe\n\ into @var{read_fd} and @var{write_fd} respectively.\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ @end deftypefn")
 DEFUNX ("WEXITSTATUS", FWEXITSTATUS, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WEXITSTATUS (@var{status})\n\ Given @var{status} from a call to @code{waitpid}, return the exit\n\ status of the child. This function should only be employed if\n\ @code{WIFEXITED} returned true.\n\ @seealso{waitpid, WIFEXITED, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ @end deftypefn")
 DEFUNX ("WIFSIGNALED", FWIFSIGNALED, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WIFSIGNALED (@var{status})\n\ Given @var{status} from a call to @code{waitpid}, return true if the\n\ child process was terminated by a signal.\n\ @seealso{waitpid, WIFEXITED, WEXITSTATUS, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ @end deftypefn")
 DEFUNX ("kill", Fkill, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} kill (@var{pid}, @var{sig})\n\ Send signal @var{sig} to process @var{pid}.\n\ \n\ If @var{pid} is positive, then signal @var{sig} is sent to @var{pid}.\n\ \n\ If @var{pid} is 0, then signal @var{sig} is sent to every process\n\ in the process group of the current process.\n\ \n\ If @var{pid} is -1, then signal @var{sig} is sent to every process\n\ except process 1.\n\ \n\ If @var{pid} is less than -1, then signal @var{sig} is sent to every\n\ process in the process group @var{-pid}.\n\ \n\ If @var{sig} is 0, then no signal is sent, but error checking is still\n\ performed.\n\ \n\ Return 0 if successful, otherwise return -1.\n\ @end deftypefn")
 DEFUNX ("fork", Ffork, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{pid}, @var{msg}] =} fork ()\n\ Create a copy of the current process.\n\ \n\ Fork can return one of the following values:\n\ \n\ @table @asis\n\ @item > 0\n\ You are in the parent process. The value returned from @code{fork} is\n\ the process id of the child process. You should probably arrange to\n\ wait for any child processes to exit.\n\ \n\ @item 0\n\ You are in the child process. You can call @code{exec} to start another\n\ process. If that fails, you should probably call @code{exit}.\n\ \n\ @item < 0\n\ The call to @code{fork} failed for some reason. You must take evasive\n\ action. A system dependent error message will be waiting in @var{msg}.\n\ @end table\n\ @end deftypefn")
 DEFUNX ("getgid", Fgetgid, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {gid =} getgid ()\n\ Return the real group id of the current process.\n\ @end deftypefn")
 DEFUNX ("S_ISFIFO", FS_ISFIFO, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISFIFO (@var{mode})\n\ Return true if @var{mode} corresponds to a fifo. The value\n\ of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn")
 DEFUNX ("getegid", Fgetegid, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {egid =} getegid ()\n\ Return the effective group id of the current process.\n\ @end deftypefn")
 DEFUNX ("popen2", Fpopen2, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{in}, @var{out}, @var{pid}] =} popen2 (@var{command}, @var{args})\n\ Start a subprocess with two-way communication. The name of the process\n\ is given by @var{command}, and @var{args} is an array of strings\n\ containing options for the command. The file identifiers for the input\n\ and output streams of the subprocess are returned in @var{in} and\n\ @var{out}. If execution of the command is successful, @var{pid}\n\ contains the process ID of the subprocess. Otherwise, @var{pid} is\n\ @minus{}1.\n\ \n\ For example:\n\ \n\ @example\n\ [in, out, pid] = popen2 (\"sort\", \"-r\");\n\ fputs (in, \"these\\nare\\nsome\\nstrings\\n\");\n\ fclose (in);\n\ EAGAIN = errno (\"EAGAIN\");\n\ done = false;\n\ do\n\ s = fgets (out);\n\ if (ischar (s))\n\ fputs (stdout, s);\n\ elseif (errno () == EAGAIN)\n\ sleep (0.1);\n\ fclear (out);\n\ else\n\ done = true;\n\ endif\n\ until (done)\n\ fclose (out);\n\ waitpid (pid);\n\ @print{} these\n\ @print{} strings\n\ @print{} some\n\ @print{} are\n\ @end example\n\ \n\ Note that @code{popen2}, unlike @code{popen}, will not \"reap\" the\n\ child process. If you don't use @code{waitpid} to check the child's\n\ exit status, it will linger until Octave exits.\n\ @end deftypefn")
 DEFUNX ("mkfifo", Fmkfifo, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\ Create a @var{fifo} special file named @var{name} with file mode @var{mode}\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ @end deftypefn")
 DEFUNX ("getpid", Fgetpid, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {pid =} getpid ()\n\ Return the process id of the current process.\n\ @end deftypefn")
 DEFUNX ("dup2", Fdup2, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} dup2 (@var{old}, @var{new})\n\ Duplicate a file descriptor.\n\ \n\ If successful, @var{fid} is greater than zero and contains the new file\n\ ID@. Otherwise, @var{fid} is negative and @var{msg} contains a\n\ system-dependent error message.\n\ @end deftypefn")
 DEFUNX ("fcntl", Ffcntl, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} fcntl (@var{fid}, @var{request}, @var{arg})\n\ Change the properties of the open file @var{fid}. The following values\n\ may be passed as @var{request}:\n\ \n\ @vtable @code\n\ @item F_DUPFD\n\ Return a duplicate file descriptor.\n\ \n\ @item F_GETFD\n\ Return the file descriptor flags for @var{fid}.\n\ \n\ @item F_SETFD\n\ Set the file descriptor flags for @var{fid}.\n\ \n\ @item F_GETFL\n\ Return the file status flags for @var{fid}. The following codes may be\n\ returned (some of the flags may be undefined on some systems).\n\ \n\ @vtable @code\n\ @item O_RDONLY\n\ Open for reading only.\n\ \n\ @item O_WRONLY\n\ Open for writing only.\n\ \n\ @item O_RDWR\n\ Open for reading and writing.\n\ \n\ @item O_APPEND\n\ Append on each write.\n\ \n\ @item O_CREAT\n\ Create the file if it does not exist.\n\ \n\ @item O_NONBLOCK\n\ Non-blocking mode.\n\ \n\ @item O_SYNC\n\ Wait for writes to complete.\n\ \n\ @item O_ASYNC\n\ Asynchronous I/O.\n\ @end vtable\n\ \n\ @item F_SETFL\n\ Set the file status flags for @var{fid} to the value specified by\n\ @var{arg}. The only flags that can be changed are @w{@code{O_APPEND}} and\n\ @w{@code{O_NONBLOCK}}.\n\ @end vtable\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ @end deftypefn")
 DEFUNX ("exec", Fexec, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} exec (@var{file}, @var{args})\n\ Replace current process with a new process. Calling @code{exec} without\n\ first calling @code{fork} will terminate your current Octave process and\n\ replace it with the program named by @var{file}. For example,\n\ \n\ @example\n\ exec (\"ls\" \"-l\")\n\ @end example\n\ \n\ @noindent\n\ will run @code{ls} and return you to your shell prompt.\n\ \n\ If successful, @code{exec} does not return. If @code{exec} does return,\n\ @var{err} will be nonzero, and @var{msg} will contain a system-dependent\n\ error message.\n\ @end deftypefn")
 DEFUNX ("WUNTRACED", FWUNTRACED, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} WUNTRACED ()\n\ Return the numerical value of the option argument that may be\n\ passed to @code{waitpid} to indicate that it should also return\n\ if the child process has stopped but is not traced via the\n\ @code{ptrace} system call\n\ @seealso{waitpid, WNOHANG, WCONTINUE}\n\ @end deftypefn")
static octave_scalar_map mk_stat_map (const base_file_stat &fs)
static octave_value_list mk_stat_result (const base_file_stat &fs)

Define Documentation

#define WCONTINUE   0

Definition at line 1928 of file syscalls.cc.

Referenced by DEFUNX().

#define WNOHANG   0

Definition at line 1895 of file syscalls.cc.

Referenced by DEFUNX().

#define WUNTRACED   0

Definition at line 1911 of file syscalls.cc.

Referenced by DEFUNX().


Function Documentation

static octave_value const_value ( const octave_value_list args,
int  val 
) [static]

Definition at line 1628 of file syscalls.cc.

References octave_value_list::length(), and print_usage().

Referenced by DEFUNX().

DEFUN ( gethostname  ,
args   
)

Definition at line 1182 of file syscalls.cc.

References octave_env::get_host_name(), and print_usage().

DEFUN ( uname  ,
args   
)
DEFUNX ( "WNOHANG"  ,
FWNOHANG  ,
args   
)

Definition at line 1898 of file syscalls.cc.

References const_value(), and WNOHANG.

DEFUNX ( "O_WRONLY"  ,
FO_WRONLY  ,
args   
)

Definition at line 1877 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "O_TRUNC"  ,
FO_TRUNC  ,
args   
)

Definition at line 1860 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "O_SYNC"  ,
FO_SYNC  ,
args   
)

Definition at line 1843 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "O_RDWR"  ,
FO_RDWR  ,
args   
)

Definition at line 1826 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "O_RDONLY"  ,
FO_RDONLY  ,
args   
)

Definition at line 1809 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "O_NONBLOCK"  ,
FO_NONBLOCK  ,
args   
)

Definition at line 1792 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "O_EXCL"  ,
FO_EXCL  ,
args   
)

Definition at line 1776 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "WCONTINUE"  ,
FWCONTINUE  ,
args   
)

Definition at line 1931 of file syscalls.cc.

References const_value(), and WCONTINUE.

DEFUNX ( "O_ASYNC"  ,
FO_ASYNC  ,
args   
)

Definition at line 1743 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "O_APPEND"  ,
FO_APPEND  ,
args   
)

Definition at line 1726 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "F_SETFL"  ,
FF_SETFL  ,
args   
)

Definition at line 1710 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "F_SETFD"  ,
FF_SETFD  ,
args   
)

Definition at line 1694 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "F_GETFL"  ,
FF_GETFL  ,
args   
)

Definition at line 1678 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "F_GETFD"  ,
FF_GETFD  ,
args   
)

Definition at line 1662 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "F_DUPFD"  ,
FF_DUPFD  ,
args   
)

Definition at line 1646 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "S_ISREG"  ,
FS_ISREG  ,
args   
)

Definition at line 1007 of file syscalls.cc.

References error(), error_state, base_file_stat::is_reg(), and print_usage().

DEFUNX ( "canonicalize_file_name"  ,
Fcanonicalize_file_name  ,
args   
)
DEFUNX ( "WIFCONTINUED"  ,
FWIFCONTINUED  ,
args   
)

Definition at line 1569 of file syscalls.cc.

References error(), error_state, and warning().

DEFUNX ( "WSTOPSIG"  ,
FWSTOPSIG  ,
args   
)

Definition at line 1541 of file syscalls.cc.

References error(), error_state, and warning().

DEFUNX ( "WIFSTOPPED"  ,
FWIFSTOPPED  ,
args   
)

Definition at line 1512 of file syscalls.cc.

References error(), error_state, and warning().

DEFUNX ( "WCOREDUMP"  ,
FWCOREDUMP  ,
args   
)

Definition at line 1482 of file syscalls.cc.

References error(), error_state, and warning().

DEFUNX ( "WTERMSIG"  ,
FWTERMSIG  ,
args   
)

Definition at line 1454 of file syscalls.cc.

References error(), error_state, and warning().

DEFUNX ( "getpgrp"  ,
Fgetpgrp  ,
args   
)
DEFUNX ( "lstat"  ,
Flstat  ,
args   
)

Definition at line 744 of file syscalls.cc.

References error_state, mk_stat_result(), and print_usage().

DEFUNX ( "WIFEXITED"  ,
FWIFEXITED  ,
args   
)

Definition at line 1372 of file syscalls.cc.

References error(), error_state, warning(), and WIFEXITED.

DEFUNX ( "waitpid"  ,
Fwaitpid  ,
args   
)
DEFUNX ( "unlink"  ,
Funlink  ,
args   
)

Definition at line 1245 of file syscalls.cc.

References error(), octave_value_list::length(), octave_unlink(), and print_usage().

DEFUNX ( "getuid"  ,
Fgetuid  ,
args   
)

Definition at line 674 of file syscalls.cc.

References octave_syscalls::getuid(), and print_usage().

DEFUNX ( "geteuid"  ,
Fgeteuid  ,
args   
)

Definition at line 656 of file syscalls.cc.

References octave_syscalls::geteuid(), and print_usage().

DEFUNX ( "S_ISSOCK"  ,
FS_ISSOCK  ,
args   
)

Definition at line 1157 of file syscalls.cc.

References error(), error_state, base_file_stat::is_sock(), and print_usage().

DEFUNX ( "S_ISLNK"  ,
FS_ISLNK  ,
args   
)

Definition at line 1132 of file syscalls.cc.

References error(), error_state, base_file_stat::is_lnk(), and print_usage().

DEFUNX ( "O_CREAT"  ,
FO_CREAT  ,
args   
)

Definition at line 1759 of file syscalls.cc.

References const_value(), error(), and octave_value().

DEFUNX ( "S_ISBLK"  ,
FS_ISBLK  ,
args   
)

Definition at line 1082 of file syscalls.cc.

References error(), error_state, base_file_stat::is_blk(), and print_usage().

DEFUNX ( "S_ISCHR"  ,
FS_ISCHR  ,
args   
)

Definition at line 1057 of file syscalls.cc.

References error(), error_state, base_file_stat::is_chr(), and print_usage().

DEFUNX ( "S_ISDIR"  ,
FS_ISDIR  ,
args   
)

Definition at line 1032 of file syscalls.cc.

References error(), error_state, base_file_stat::is_dir(), and print_usage().

DEFUNX ( "getppid"  ,
Fgetppid  ,
args   
)

Definition at line 602 of file syscalls.cc.

References octave_syscalls::getppid(), and print_usage().

DEFUNX ( "stat"  ,
Fstat  ,
args   
)
DEFUNX ( "pipe"  ,
Fpipe  ,
args   
)
DEFUNX ( "WEXITSTATUS"  ,
FWEXITSTATUS  ,
args   
)

Definition at line 1399 of file syscalls.cc.

References error(), error_state, warning(), and WEXITSTATUS.

DEFUNX ( "WIFSIGNALED"  ,
FWIFSIGNALED  ,
args   
)

Definition at line 1427 of file syscalls.cc.

References error(), error_state, and warning().

DEFUNX ( "kill"  ,
Fkill  ,
args   
)

Definition at line 692 of file syscalls.cc.

References error_state, octave_syscalls::kill(), and print_usage().

DEFUNX ( "fork"  ,
Ffork  ,
args   
)

Definition at line 513 of file syscalls.cc.

References octave_syscalls::fork(), octave_value_list::length(), and print_usage().

DEFUNX ( "getgid"  ,
Fgetgid  ,
args   
)

Definition at line 638 of file syscalls.cc.

References octave_syscalls::getgid(), and print_usage().

DEFUNX ( "S_ISFIFO"  ,
FS_ISFIFO  ,
args   
)

Definition at line 1107 of file syscalls.cc.

References error(), error_state, base_file_stat::is_fifo(), and print_usage().

DEFUNX ( "getegid"  ,
Fgetegid  ,
args   
)

Definition at line 620 of file syscalls.cc.

References octave_syscalls::getegid(), and print_usage().

DEFUNX ( "popen2"  ,
Fpopen2  ,
args   
)
DEFUNX ( "mkfifo"  ,
Fmkfifo  ,
args   
)
DEFUNX ( "getpid"  ,
Fgetpid  ,
args   
)

Definition at line 584 of file syscalls.cc.

References octave_syscalls::getpid(), and print_usage().

DEFUNX ( "dup2"  ,
Fdup2  ,
args   
)
DEFUNX ( "fcntl"  ,
Ffcntl  ,
args   
)
DEFUNX ( "exec"  ,
Fexec  ,
args   
)
DEFUNX ( "WUNTRACED"  ,
FWUNTRACED  ,
args   
)

Definition at line 1914 of file syscalls.cc.

References const_value(), and WUNTRACED.

static octave_scalar_map mk_stat_map ( const base_file_stat fs  )  [static]
static octave_value_list mk_stat_result ( const base_file_stat fs  )  [static]

Definition at line 90 of file syscalls.cc.

References base_file_stat::error(), mk_stat_map(), and octave_value().

Referenced by DEFUNX().

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines