summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-29 01:17:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-29 01:17:39 +0000
commit63dedc7de4877eb4d7fba2716a2eeedb31efa794 (patch)
tree622c5f2d6b32fb304a87b2a7a513e289606af4fe /process.c
parentc7558580f67c81dd03b1a7f1672545adf9d6ce9a (diff)
* io.c (rb_io_popen): update the document for the first argument and
exceptions. * process.c (rb_f_exec, rb_f_system): update the document for exceptions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c320
1 files changed, 161 insertions, 159 deletions
diff --git a/process.c b/process.c
index b422308b2e..da7409abcf 100644
--- a/process.c
+++ b/process.c
@@ -115,10 +115,10 @@ static VALUE S_Tms;
/*
* call-seq:
* Process.pid => fixnum
- *
+ *
* Returns the process id of this process. Not available on all
* platforms.
- *
+ *
* Process.pid #=> 27415
*/
@@ -132,15 +132,15 @@ get_pid()
/*
* call-seq:
* Process.ppid => fixnum
- *
+ *
* Returns the process id of the parent of this process. Always
* returns 0 on NT. Not available on all platforms.
- *
+ *
* puts "I am #{Process.pid}"
* Process.fork { puts "Dad is #{Process.ppid}" }
- *
+ *
* <em>produces:</em>
- *
+ *
* I am 27417
* Dad is 27417
*/
@@ -164,7 +164,7 @@ get_ppid()
* status of a running or terminated system process. The built-in
* variable <code>$?</code> is either +nil+ or a
* <code>Process::Status</code> object.
- *
+ *
* fork { exit 99 } #=> 26557
* Process.wait #=> 26557
* $?.class #=> Process::Status
@@ -173,7 +173,7 @@ get_ppid()
* $?.stopped? #=> false
* $?.exited? #=> true
* $?.exitstatus #=> 99
- *
+ *
* Posix systems record information on processes using a 16-bit
* integer. The lower bits record the process status (stopped,
* exited, signaled) and the upper bits possibly contain additional
@@ -203,10 +203,10 @@ last_status_set(status, pid)
* call-seq:
* stat.to_i => fixnum
* stat.to_int => fixnum
- *
+ *
* Returns the bits in _stat_ as a <code>Fixnum</code>. Poking
* around in these bits is platform dependent.
- *
+ *
* fork { exit 0xab } #=> 26566
* Process.wait #=> 26566
* sprintf('%04x', $?.to_i) #=> "ab00"
@@ -223,7 +223,7 @@ pst_to_i(st)
/*
* call-seq:
* stat.to_s => string
- *
+ *
* Equivalent to _stat_<code>.to_i.to_s</code>.
*/
@@ -238,9 +238,9 @@ pst_to_s(st)
/*
* call-seq:
* stat.pid => fixnum
- *
+ *
* Returns the process ID that this status object represents.
- *
+ *
* fork { exit } #=> 26569
* Process.wait #=> 26569
* $?.pid #=> 26569
@@ -257,7 +257,7 @@ pst_pid(st)
/*
* call-seq:
* stat.inspect => string
- *
+ *
* Override the inspection method.
*/
@@ -314,7 +314,7 @@ pst_inspect(st)
/*
* call-seq:
* stat == other => true or false
- *
+ *
* Returns +true+ if the integer value of _stat_
* equals <em>other</em>.
*/
@@ -331,9 +331,9 @@ pst_equal(st1, st2)
/*
* call-seq:
* stat & num => fixnum
- *
+ *
* Logical AND of the bits in _stat_ with <em>num</em>.
- *
+ *
* fork { exit 0x37 }
* Process.wait
* sprintf('%04x', $?.to_i) #=> "3700"
@@ -353,9 +353,9 @@ pst_bitand(st1, st2)
/*
* call-seq:
* stat >> num => fixnum
- *
+ *
* Shift the bits in _stat_ right <em>num</em> places.
- *
+ *
* fork { exit 99 } #=> 26563
* Process.wait #=> 26563
* $?.to_i #=> 25344
@@ -375,7 +375,7 @@ pst_rshift(st1, st2)
/*
* call-seq:
* stat.stopped? => true or false
- *
+ *
* Returns +true+ if this process is stopped. This is only
* returned if the corresponding <code>wait</code> call had the
* <code>WUNTRACED</code> flag set.
@@ -397,7 +397,7 @@ pst_wifstopped(st)
/*
* call-seq:
* stat.stopsig => fixnum or nil
- *
+ *
* Returns the number of the signal that caused _stat_ to stop
* (or +nil+ if self is not stopped).
*/
@@ -417,7 +417,7 @@ pst_wstopsig(st)
/*
* call-seq:
* stat.signaled? => true or false
- *
+ *
* Returns +true+ if _stat_ terminated because of
* an uncaught signal.
*/
@@ -438,7 +438,7 @@ pst_wifsignaled(st)
/*
* call-seq:
* stat.termsig => fixnum or nil
- *
+ *
* Returns the number of the signal that caused _stat_ to
* terminate (or +nil+ if self was not terminated by an
* uncaught signal).
@@ -459,7 +459,7 @@ pst_wtermsig(st)
/*
* call-seq:
* stat.exited? => true or false
- *
+ *
* Returns +true+ if _stat_ exited normally (for
* example using an <code>exit()</code> call or finishing the
* program).
@@ -481,16 +481,16 @@ pst_wifexited(st)
/*
* call-seq:
* stat.exitstatus => fixnum or nil
- *
+ *
* Returns the least significant eight bits of the return code of
* _stat_. Only available if <code>exited?</code> is
* +true+.
- *
+ *
* fork { } #=> 26572
* Process.wait #=> 26572
* $?.exited? #=> true
* $?.exitstatus #=> 0
- *
+ *
* fork { exit 99 } #=> 26573
* Process.wait #=> 26573
* $?.exited? #=> true
@@ -512,7 +512,7 @@ pst_wexitstatus(st)
/*
* call-seq:
* stat.success? => true, false or nil
- *
+ *
* Returns +true+ if _stat_ is successful, +false+ if not.
* Returns +nil+ if <code>exited?</code> is not +true+.
*/
@@ -532,7 +532,7 @@ pst_success_p(st)
/*
* call-seq:
* stat.coredump? => true or false
- *
+ *
* Returns +true+ if _stat_ generated a coredump
* when it terminated. Not available on all platforms.
*/
@@ -678,20 +678,20 @@ waitall_each(pid, status, ary)
* Process.wait() => fixnum
* Process.wait(pid=-1, flags=0) => fixnum
* Process.waitpid(pid=-1, flags=0) => fixnum
- *
+ *
* Waits for a child process to exit, returns its process id, and
* sets <code>$?</code> to a <code>Process::Status</code> object
* containing information on that process. Which child it waits on
* depends on the value of _pid_:
- *
+ *
* > 0:: Waits for the child whose process ID equals _pid_.
- *
+ *
* 0:: Waits for any child whose process group ID equals that of the
* calling process.
*
* -1:: Waits for any child process (the default if no _pid_ is
* given).
- *
+ *
* < -1:: Waits for any child whose process group ID equals the absolute
* value of _pid_.
*
@@ -700,10 +700,10 @@ waitall_each(pid, status, ary)
* or <code>Process::WUNTRACED</code> (return stopped children that
* haven't been reported). Not all flags are available on all
* platforms, but a flag value of zero will work on all platforms.
- *
+ *
* Calling this method raises a <code>SystemError</code> if there are
* no child processes. Not available on all platforms.
- *
+ *
* include Process
* fork { exit 99 } #=> 27429
* wait #=> 27429
@@ -749,13 +749,13 @@ proc_wait(argc, argv)
* call-seq:
* Process.wait2(pid=-1, flags=0) => [pid, status]
* Process.waitpid2(pid=-1, flags=0) => [pid, status]
- *
+ *
* Waits for a child process to exit (see Process::waitpid for exact
* semantics) and returns an array containing the process id and the
* exit status (a <code>Process::Status</code> object) of that
* child. Raises a <code>SystemError</code> if there are no child
* processes.
- *
+ *
* Process.fork { exit 99 } #=> 27437
* pid, status = Process.wait2
* pid #=> 27437
@@ -776,11 +776,11 @@ proc_wait2(argc, argv)
/*
* call-seq:
* Process.waitall => [ [pid1,status1], ...]
- *
+ *
* Waits for all children, returning an array of
* _pid_/_status_ pairs (where _status_ is a
* <code>Process::Status</code> object).
- *
+ *
* fork { sleep 0.2; exit 2 } #=> 27432
* fork { sleep 0.1; exit 1 } #=> 27433
* fork { exit 0 } #=> 27434
@@ -858,7 +858,7 @@ rb_detach_process(pid)
/*
* call-seq:
* Process.detach(pid) => thread
- *
+ *
* Some operating systems retain the status of terminated child
* processes until the parent collects that status (normally using
* some variant of <code>wait()</code>. If the parent never collects
@@ -877,27 +877,27 @@ rb_detach_process(pid)
*
* In this first example, we don't reap the first child process, so
* it appears as a zombie in the process status display.
- *
+ *
* p1 = fork { sleep 0.1 }
* p2 = fork { sleep 0.2 }
* Process.waitpid(p2)
* sleep 2
* system("ps -ho pid,state -p #{p1}")
- *
+ *
* <em>produces:</em>
- *
+ *
* 27389 Z
- *
+ *
* In the next example, <code>Process::detach</code> is used to reap
* the child automatically.
- *
+ *
* p1 = fork { sleep 0.1 }
* p2 = fork { sleep 0.2 }
* Process.detach(p1)
* Process.waitpid(p2)
* sleep 2
* system("ps -ho pid,state -p #{p1}")
- *
+ *
* <em>(produces no output)</em>
*/
@@ -1211,7 +1211,7 @@ rb_check_argv(argc, argv)
/*
* call-seq:
* exec(command [, arg, ...])
- *
+ *
* Replaces the current process by running the given external _command_.
* If +exec+ is given a single argument, that argument is
* taken as a line that is subject to shell expansion before being
@@ -1224,11 +1224,14 @@ rb_check_argv(argc, argv)
* subshell; otherwise, one of the <code>exec(2)</code> system calls is
* used, so the running command may inherit some of the environment of
* the original program (including open file descriptors).
- *
+ *
+ * Raises SystemCallError if the _command_ couldn't execute (typically
+ * <code>Errno::ENOENT</code> when it was not found).
+ *
* exec "echo *" # echoes list of files in current directory
* # never get here
- *
- *
+ *
+ *
* exec "echo", "*" # echoes an asterisk
* # never get here
*/
@@ -1405,7 +1408,7 @@ rb_fork(status, chfunc, charg)
/*
* call-seq:
* Process.fork [{ block }] => fixnum or nil
- *
+ *
* See <code>Kernel::fork</code>.
*/
@@ -1448,11 +1451,11 @@ rb_f_fork(obj)
/*
* call-seq:
* Process.exit!(fixnum=-1)
- *
+ *
* Exits the process immediately. No exit handlers are
* run. <em>fixnum</em> is returned to the underlying system as the
* exit status.
- *
+ *
* Process.exit!(0)
*/
@@ -1572,18 +1575,17 @@ rb_spawn(argc, argv)
/*
* call-seq:
* system(cmd [, arg, ...]) => true or false
- *
- * Executes _cmd_ in a subshell, returning +true+ if
- * the command was found and ran successfully, +false+
- * otherwise. An error status is available in <code>$?</code>. The
- * arguments are processed in the same way as for
- * <code>Kernel::exec</code>.
- *
+ *
+ * Executes _cmd_ in a subshell, returning +true+ if the command ran
+ * successfully, +false+ otherwise. An error status is available in
+ * <code>$?</code>. The arguments are processed in the same way as
+ * for <code>Kernel::exec</code>, and raises same exceptions as it.
+ *
* system("echo *")
* system("echo", "*")
- *
+ *
* <em>produces:</em>
- *
+ *
* config.h main.rb
* *
*/
@@ -1632,14 +1634,14 @@ rb_f_spawn(argc, argv)
/*
* call-seq:
* sleep(duration=0) => fixnum
- *
+ *
* Suspends the current thread for _duration_ seconds (which may be
* any number, including a +Float+ with fractional seconds). Returns the actual
* number of seconds slept (rounded), which may be less than that asked
* for if the thread was interrupted by a +SIGALRM+, or if
* another thread calls <code>Thread#run</code>. An argument of zero
* causes +sleep+ to sleep forever.
- *
+ *
* Time.new #=> Wed Apr 09 08:56:32 CDT 2003
* sleep 1.2 #=> 1
* Time.new #=> Wed Apr 09 08:56:33 CDT 2003
@@ -1674,10 +1676,10 @@ rb_f_sleep(argc, argv)
/*
* call-seq:
* Process.getpgrp => integer
- *
+ *
* Returns the process group ID for this process. Not available on
* all platforms.
- *
+ *
* Process.getpgid(0) #=> 25527
* Process.getpgrp #=> 25527
*/
@@ -1706,7 +1708,7 @@ proc_getpgrp()
/*
* call-seq:
* Process.setpgrp => 0
- *
+ *
* Equivalent to <code>setpgid(0,0)</code>. Not available on all
* platforms.
*/
@@ -1732,10 +1734,10 @@ proc_setpgrp()
/*
* call-seq:
* Process.getpgid(pid) => integer
- *
+ *
* Returns the process group ID for the given process id. Not
* available on all platforms.
- *
+ *
* Process.getpgid(Process.ppid()) #=> 25527
*/
@@ -1757,7 +1759,7 @@ proc_getpgid(obj, pid)
/*
* call-seq:
* Process.setpgid(pid, integer) => 0
- *
+ *
* Sets the process group ID of _pid_ (0 indicates this
* process) to <em>integer</em>. Not available on all platforms.
*/
@@ -1784,11 +1786,11 @@ proc_setpgid(obj, pid, pgrp)
/*
* call-seq:
* Process.setsid => fixnum
- *
+ *
* Establishes this process as a new session and process group
* leader, with no controlling tty. Returns the session id. Not
* available on all platforms.
- *
+ *
* Process.setsid #=> 27422
*/
@@ -1832,7 +1834,7 @@ proc_setsid()
/*
* call-seq:
* Process.getpriority(kind, integer) => fixnum
- *
+ *
* Gets the scheduling priority for specified process, process group,
* or user. <em>kind</em> indicates the kind of entity to find: one
* of <code>Process::PRIO_PGRP</code>,
@@ -1841,7 +1843,7 @@ proc_setsid()
* indicating the particular process, process group, or user (an id
* of 0 means _current_). Lower priorities are more favorable
* for scheduling. Not available on all platforms.
- *
+ *
* Process.getpriority(Process::PRIO_USER, 0) #=> 19
* Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19
*/
@@ -1869,9 +1871,9 @@ proc_getpriority(obj, which, who)
/*
* call-seq:
* Process.setpriority(kind, integer, priority) => 0
- *
+ *
* See <code>Process#getpriority</code>.
- *
+ *
* Process.setpriority(Process::PRIO_USER, 0, 19) #=> 0
* Process.setpriority(Process::PRIO_PROCESS, 0, 19) #=> 0
* Process.getpriority(Process::PRIO_USER, 0) #=> 19
@@ -1933,10 +1935,10 @@ check_gid_switch()
/*
* call-seq:
* Process::Sys.setuid(integer) => nil
- *
+ *
* Set the user ID of the current process to _integer_. Not
* available on all platforms.
- *
+ *
*/
static VALUE
@@ -1957,10 +1959,10 @@ p_sys_setuid(obj, id)
/*
* call-seq:
* Process::Sys.setruid(integer) => nil
- *
+ *
* Set the real user ID of the calling process to _integer_.
* Not available on all platforms.
- *
+ *
*/
static VALUE
@@ -1980,10 +1982,10 @@ p_sys_setruid(obj, id)
/*
* call-seq:
* Process::Sys.seteuid(integer) => nil
- *
+ *
* Set the effective user ID of the calling process to
* _integer_. Not available on all platforms.
- *
+ *
*/
static VALUE
@@ -2003,7 +2005,7 @@ p_sys_seteuid(obj, id)
/*
* call-seq:
* Process::Sys.setreuid(rid, eid) => nil
- *
+ *
* Sets the (integer) real and/or effective user IDs of the current
* process to _rid_ and _eid_, respectively. A value of
* <code>-1</code> for either means to leave that ID unchanged. Not
@@ -2028,9 +2030,9 @@ p_sys_setreuid(obj, rid, eid)
/*
* call-seq:
* Process::Sys.setresuid(rid, eid, sid) => nil
- *
+ *
* Sets the (integer) real, effective, and saved user IDs of the
- * current process to _rid_, _eid_, and _sid_ respectively. A
+ * current process to _rid_, _eid_, and _sid_ respectively. A
* value of <code>-1</code> for any value means to
* leave that ID unchanged. Not available on all platforms.
*
@@ -2055,9 +2057,9 @@ p_sys_setresuid(obj, rid, eid, sid)
* Process.uid => fixnum
* Process::UID.rid => fixnum
* Process::Sys.getuid => fixnum
- *
+ *
* Returns the (real) user ID of this process.
- *
+ *
* Process.uid #=> 501
*/
@@ -2073,7 +2075,7 @@ proc_getuid(obj)
/*
* call-seq:
* Process.uid= integer => numeric
- *
+ *
* Sets the (integer) user ID for this process. Not available on all
* platforms.
*/
@@ -2108,7 +2110,7 @@ proc_setuid(obj, id)
/********************************************************************
- *
+ *
* Document-class: Process::UID
*
* The <code>Process::UID</code> module contains a collection of
@@ -2123,11 +2125,11 @@ static int SAVED_USER_ID;
/*
* call-seq:
* Process::UID.change_privilege(integer) => fixnum
- *
+ *
* Change the current process's real and effective user ID to that
* specified by _integer_. Returns the new user ID. Not
* available on all platforms.
- *
+ *
* [Process.uid, Process.euid] #=> [0, 0]
* Process::UID.change_privilege(31) #=> 31
* [Process.uid, Process.euid] #=> [31, 31]
@@ -2200,13 +2202,13 @@ p_uid_change_privilege(obj, id)
#endif
} else { /* unprivileged user */
#if defined(HAVE_SETRESUID)
- if (setresuid((getuid() == uid)? -1: uid,
- (geteuid() == uid)? -1: uid,
+ if (setresuid((getuid() == uid)? -1: uid,
+ (geteuid() == uid)? -1: uid,
(SAVED_USER_ID == uid)? -1: uid) < 0) rb_sys_fail(0);
SAVED_USER_ID = uid;
#elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID)
if (SAVED_USER_ID == uid) {
- if (setreuid((getuid() == uid)? -1: uid,
+ if (setreuid((getuid() == uid)? -1: uid,
(geteuid() == uid)? -1: uid) < 0) rb_sys_fail(0);
} else if (getuid() != uid) {
if (setreuid(uid, (geteuid() == uid)? -1: uid) < 0) rb_sys_fail(0);
@@ -2278,10 +2280,10 @@ p_uid_change_privilege(obj, id)
/*
* call-seq:
* Process::Sys.setgid(integer) => nil
- *
+ *
* Set the group ID of the current process to _integer_. Not
* available on all platforms.
- *
+ *
*/
static VALUE
@@ -2301,10 +2303,10 @@ p_sys_setgid(obj, id)
/*
* call-seq:
* Process::Sys.setrgid(integer) => nil
- *
+ *
* Set the real group ID of the calling process to _integer_.
* Not available on all platforms.
- *
+ *
*/
static VALUE
@@ -2325,10 +2327,10 @@ p_sys_setrgid(obj, id)
/*
* call-seq:
* Process::Sys.setegid(integer) => nil
- *
+ *
* Set the effective group ID of the calling process to
* _integer_. Not available on all platforms.
- *
+ *
*/
static VALUE
@@ -2348,7 +2350,7 @@ p_sys_setegid(obj, id)
/*
* call-seq:
* Process::Sys.setregid(rid, eid) => nil
- *
+ *
* Sets the (integer) real and/or effective group IDs of the current
* process to <em>rid</em> and <em>eid</em>, respectively. A value of
* <code>-1</code> for either means to leave that ID unchanged. Not
@@ -2372,7 +2374,7 @@ p_sys_setregid(obj, rid, eid)
/*
* call-seq:
* Process::Sys.setresgid(rid, eid, sid) => nil
- *
+ *
* Sets the (integer) real, effective, and saved user IDs of the
* current process to <em>rid</em>, <em>eid</em>, and <em>sid</em>
* respectively. A value of <code>-1</code> for any value means to
@@ -2397,7 +2399,7 @@ p_sys_setresgid(obj, rid, eid, sid)
/*
* call-seq:
* Process::Sys.issetugid => true or false
- *
+ *
* Returns +true+ if the process was created as a result
* of an execve(2) system call which had either of the setuid or
* setgid bits set (and extra privileges were given as a result) or
@@ -2428,9 +2430,9 @@ p_sys_issetugid(obj)
* Process.gid => fixnum
* Process::GID.rid => fixnum
* Process::Sys.getgid => fixnum
- *
+ *
* Returns the (real) group ID for this process.
- *
+ *
* Process.gid #=> 500
*/
@@ -2446,7 +2448,7 @@ proc_getgid(obj)
/*
* call-seq:
* Process.gid= fixnum => fixnum
- *
+ *
* Sets the group ID for this process.
*/
@@ -2485,7 +2487,7 @@ static size_t maxgroups = 32;
/*
* call-seq:
* Process.groups => array
- *
+ *
* Get an <code>Array</code> of the gids of groups in the
* supplemental group access list for this process.
*
@@ -2523,7 +2525,7 @@ proc_getgroups(VALUE obj)
/*
* call-seq:
* Process.groups= array => array
- *
+ *
* Set the supplemental group access list to the given
* <code>Array</code> of group IDs.
*
@@ -2565,7 +2567,7 @@ proc_setgroups(VALUE obj, VALUE ary)
else {
gr = getgrnam(RSTRING(g)->ptr);
if (gr == NULL)
- rb_raise(rb_eArgError,
+ rb_raise(rb_eArgError,
"can't find group for %s", RSTRING(g)->ptr);
groups[i] = gr->gr_gid;
}
@@ -2587,7 +2589,7 @@ proc_setgroups(VALUE obj, VALUE ary)
/*
* call-seq:
* Process.initgroups(username, gid) => array
- *
+ *
* Initializes the supplemental group access list by reading the
* system group database and using all groups of which the given user
* is a member. The group with the specified <em>gid</em> is also
@@ -2620,10 +2622,10 @@ proc_initgroups(obj, uname, base_grp)
/*
* call-seq:
* Process.maxgroups => fixnum
- *
+ *
* Returns the maximum number of gids allowed in the supplemental
* group access list.
- *
+ *
* Process.maxgroups #=> 32
*/
@@ -2638,7 +2640,7 @@ proc_getmaxgroups(obj)
/*
* call-seq:
* Process.maxgroups= fixnum => fixnum
- *
+ *
* Sets the maximum number of gids allowed in the supplemental group
* access list.
*/
@@ -2659,7 +2661,7 @@ proc_setmaxgroups(obj, val)
/********************************************************************
- *
+ *
* Document-class: Process::GID
*
* The <code>Process::GID</code> module contains a collection of
@@ -2674,7 +2676,7 @@ static int SAVED_GROUP_ID;
/*
* call-seq:
* Process::GID.change_privilege(integer) => fixnum
- *
+ *
* Change the current process's real and effective group ID to that
* specified by _integer_. Returns the new group ID. Not
* available on all platforms.
@@ -2752,13 +2754,13 @@ p_gid_change_privilege(obj, id)
#endif
} else { /* unprivileged user */
#if defined(HAVE_SETRESGID)
- if (setresgid((getgid() == gid)? -1: gid,
- (getegid() == gid)? -1: gid,
+ if (setresgid((getgid() == gid)? -1: gid,
+ (getegid() == gid)? -1: gid,
(SAVED_GROUP_ID == gid)? -1: gid) < 0) rb_sys_fail(0);
SAVED_GROUP_ID = gid;
#elif defined(HAVE_SETREGID) && !defined(OBSOLETE_SETREGID)
if (SAVED_GROUP_ID == gid) {
- if (setregid((getgid() == gid)? -1: gid,
+ if (setregid((getgid() == gid)? -1: gid,
(getegid() == gid)? -1: gid) < 0) rb_sys_fail(0);
} else if (getgid() != gid) {
if (setregid(gid, (getegid() == gid)? -1: gid) < 0) rb_sys_fail(0);
@@ -2831,9 +2833,9 @@ p_gid_change_privilege(obj, id)
* Process.euid => fixnum
* Process::UID.eid => fixnum
* Process::Sys.geteuid => fixnum
- *
+ *
* Returns the effective user ID for this process.
- *
+ *
* Process.euid #=> 501
*/
@@ -2849,7 +2851,7 @@ proc_geteuid(obj)
/*
* call-seq:
* Process.euid= integer
- *
+ *
* Sets the effective user ID for this process. Not available on all
* platforms.
*/
@@ -2919,11 +2921,11 @@ rb_seteuid_core(euid)
* call-seq:
* Process::UID.grant_privilege(integer) => fixnum
* Process::UID.eid= integer => fixnum
- *
+ *
* Set the effective user ID, and if possible, the saved user ID of
* the process to the given _integer_. Returns the new
* effective user ID. Not available on all platforms.
- *
+ *
* [Process.uid, Process.euid] #=> [0, 0]
* Process::UID.grant_privilege(31) #=> 31
* [Process.uid, Process.euid] #=> [0, 31]
@@ -2942,10 +2944,10 @@ p_uid_grant_privilege(obj, id)
* Process.egid => fixnum
* Process::GID.eid => fixnum
* Process::Sys.geteid => fixnum
- *
+ *
* Returns the effective group ID for this process. Not available on
* all platforms.
- *
+ *
* Process.egid #=> 500
*/
@@ -2962,7 +2964,7 @@ proc_getegid(obj)
/*
* call-seq:
* Process.egid = fixnum => fixnum
- *
+ *
* Sets the effective group ID for this process. Not available on all
* platforms.
*/
@@ -3033,11 +3035,11 @@ rb_setegid_core(egid)
* call-seq:
* Process::GID.grant_privilege(integer) => fixnum
* Process::GID.eid = integer => fixnum
- *
+ *
* Set the effective group ID, and if possible, the saved group ID of
* the process to the given _integer_. Returns the new
* effective group ID. Not available on all platforms.
- *
+ *
* [Process.gid, Process.egid] #=> [0, 0]
* Process::GID.grant_privilege(31) #=> 33
* [Process.gid, Process.egid] #=> [0, 33]
@@ -3054,10 +3056,10 @@ p_gid_grant_privilege(obj, id)
/*
* call-seq:
* Process::UID.re_exchangeable? => true or false
- *
+ *
* Returns +true+ if the real and effective user IDs of a
* process may be exchanged on the current platform.
- *
+ *
*/
static VALUE
@@ -3076,10 +3078,10 @@ p_uid_exchangeable()
/*
* call-seq:
* Process::UID.re_exchange => fixnum
- *
+ *
* Exchange real and effective user IDs and return the new effective
* user ID. Not available on all platforms.
- *
+ *
* [Process.uid, Process.euid] #=> [0, 31]
* Process::UID.re_exchange #=> 0
* [Process.uid, Process.euid] #=> [31, 0]
@@ -3112,10 +3114,10 @@ p_uid_exchange(obj)
/*
* call-seq:
* Process::GID.re_exchangeable? => true or false
- *
+ *
* Returns +true+ if the real and effective group IDs of a
* process may be exchanged on the current platform.
- *
+ *
*/
static VALUE
@@ -3134,10 +3136,10 @@ p_gid_exchangeable()
/*
* call-seq:
* Process::GID.re_exchange => fixnum
- *
+ *
* Exchange real and effective group IDs and return the new effective
* group ID. Not available on all platforms.
- *
+ *
* [Process.gid, Process.egid] #=> [0, 33]
* Process::GID.re_exchange #=> 0
* [Process.gid, Process.egid] #=> [33, 0]
@@ -3171,10 +3173,10 @@ p_gid_exchange(obj)
/*
* call-seq:
* Process::UID.sid_available? => true or false
- *
+ *
* Returns +true+ if the current platform has saved user
* ID functionality.
- *
+ *
*/
static VALUE
@@ -3202,13 +3204,13 @@ p_uid_sw_ensure(id)
* call-seq:
* Process::UID.switch => fixnum
* Process::UID.switch {|| block} => object
- *
+ *
* Switch the effective and real user IDs of the current process. If
* a <em>block</em> is given, the user IDs will be switched back
* after the block is executed. Returns the new effective user ID if
* called without a block, and the return value of the block if one
* is given.
- *
+ *
*/
static VALUE
@@ -3285,10 +3287,10 @@ p_uid_switch(obj)
/*
* call-seq:
* Process::GID.sid_available? => true or false
- *
+ *
* Returns +true+ if the current platform has saved group
* ID functionality.
- *
+ *
*/
static VALUE
@@ -3315,13 +3317,13 @@ p_gid_sw_ensure(id)
* call-seq:
* Process::GID.switch => fixnum
* Process::GID.switch {|| block} => object
- *
+ *
* Switch the effective and real group IDs of the current process. If
* a <em>block</em> is given, the group IDs will be switched back
* after the block is executed. Returns the new effective group ID if
* called without a block, and the return value of the block if one
* is given.
- *
+ *
*/
static VALUE
@@ -3395,11 +3397,11 @@ p_gid_switch(obj)
/*
* call-seq:
* Process.times => aStructTms
- *
+ *
* Returns a <code>Tms</code> structure (see <code>Struct::Tms</code>
* on page 388) that contains user and system CPU times for this
* process.
- *
+ *
* t = Process.times
* [ t.utime, t.stime ] #=> [0.0, 0.02]
*/
@@ -3553,25 +3555,25 @@ Init_process()
rb_define_module_function(rb_mProcGID, "rid", proc_getgid, 0);
rb_define_module_function(rb_mProcUID, "eid", proc_geteuid, 0);
rb_define_module_function(rb_mProcGID, "eid", proc_getegid, 0);
- rb_define_module_function(rb_mProcUID, "change_privilege",
+ rb_define_module_function(rb_mProcUID, "change_privilege",
p_uid_change_privilege, 1);
- rb_define_module_function(rb_mProcGID, "change_privilege",
+ rb_define_module_function(rb_mProcGID, "change_privilege",
p_gid_change_privilege, 1);
- rb_define_module_function(rb_mProcUID, "grant_privilege",
+ rb_define_module_function(rb_mProcUID, "grant_privilege",
p_uid_grant_privilege, 1);
- rb_define_module_function(rb_mProcGID, "grant_privilege",
+ rb_define_module_function(rb_mProcGID, "grant_privilege",
p_gid_grant_privilege, 1);
rb_define_alias(rb_mProcUID, "eid=", "grant_privilege");
rb_define_alias(rb_mProcGID, "eid=", "grant_privilege");
rb_define_module_function(rb_mProcUID, "re_exchange", p_uid_exchange, 0);
rb_define_module_function(rb_mProcGID, "re_exchange", p_gid_exchange, 0);
- rb_define_module_function(rb_mProcUID, "re_exchangeable?",
+ rb_define_module_function(rb_mProcUID, "re_exchangeable?",
p_uid_exchangeable, 0);
- rb_define_module_function(rb_mProcGID, "re_exchangeable?",
+ rb_define_module_function(rb_mProcGID, "re_exchangeable?",
p_gid_exchangeable, 0);
- rb_define_module_function(rb_mProcUID, "sid_available?",
+ rb_define_module_function(rb_mProcUID, "sid_available?",
p_uid_have_saved_id, 0);
- rb_define_module_function(rb_mProcGID, "sid_available?",
+ rb_define_module_function(rb_mProcGID, "sid_available?",
p_gid_have_saved_id, 0);
rb_define_module_function(rb_mProcUID, "switch", p_uid_switch, 0);
rb_define_module_function(rb_mProcGID, "switch", p_gid_switch, 0);
@@ -3592,15 +3594,15 @@ Init_process()
rb_define_module_function(rb_mProcID_Syscall, "seteuid", p_sys_seteuid, 1);
rb_define_module_function(rb_mProcID_Syscall, "setegid", p_sys_setegid, 1);
- rb_define_module_function(rb_mProcID_Syscall, "setreuid",
+ rb_define_module_function(rb_mProcID_Syscall, "setreuid",
p_sys_setreuid, 2);
- rb_define_module_function(rb_mProcID_Syscall, "setregid",
+ rb_define_module_function(rb_mProcID_Syscall, "setregid",
p_sys_setregid, 2);
- rb_define_module_function(rb_mProcID_Syscall, "setresuid",
+ rb_define_module_function(rb_mProcID_Syscall, "setresuid",
p_sys_setresuid, 3);
- rb_define_module_function(rb_mProcID_Syscall, "setresgid",
+ rb_define_module_function(rb_mProcID_Syscall, "setresgid",
p_sys_setresgid, 3);
- rb_define_module_function(rb_mProcID_Syscall, "issetugid",
+ rb_define_module_function(rb_mProcID_Syscall, "issetugid",
p_sys_issetugid, 0);
}