Chris Marusich
2018-10-13 20:26:59 UTC
Hi,
I was reading about the "system" and "system*" procedures in the Guile
manual, and it seems like the actual behavior of Guile seems to
contradict what the manual says. I'm using Guile version 2.2.4.
The Guile manual says that these procedures return the exit status as
returned by waitpid:
-- Scheme Procedure: system [cmd]
-- C Function: scm_system (cmd)
Execute CMD using the operating systemâs âcommand processorâ.
Under Unix this is usually the default shell âshâ. The value
returned is CMDâs exit status as returned by âwaitpidâ [...].
-- Scheme Procedure: system* arg1 arg2 ...
-- C Function: scm_system_star (args)
[...]
This function returns the exit status of the command as provided by
âwaitpidâ. This value can be handled with âstatus:exit-valâ and
the related functions.
[...]
And the documentation for "waitpid" says:
-- Scheme Procedure: waitpid pid [options]
-- C Function: scm_waitpid (pid, options)
[...]
The return value is a pair containing:
1. The process ID of the child process, or 0 if âWNOHANGâ was
specified and no process was collected.
2. The integer status value.
However, the return value doesn't appear to be a pair:
scheme@(guile-user)> (system "true")
$1 = 0
scheme@(guile-user)> (pair? $1)
$2 = #f
scheme@(guile-user)> (system* "true")
$3 = 0
scheme@(guile-user)> (pair? $3)
$4 = #f
scheme@(guile-user)>
In spite of this, the procedures like status:exit-val do seem to work as
expected:
scheme@(guile-user)> (status:exit-val $1)
$5 = 0
scheme@(guile-user)> (status:exit-val $3)
$6 = 0
Is the documentation incorrect? I checked the Guile source for the
system procedure, and it seemed to me like the documentation is
incorrect, but I'm not 100% sure, since I'm not very familiar with the
Guile source code, so I thought I'd ask here to make sure.
Thank you for your help!
I was reading about the "system" and "system*" procedures in the Guile
manual, and it seems like the actual behavior of Guile seems to
contradict what the manual says. I'm using Guile version 2.2.4.
The Guile manual says that these procedures return the exit status as
returned by waitpid:
-- Scheme Procedure: system [cmd]
-- C Function: scm_system (cmd)
Execute CMD using the operating systemâs âcommand processorâ.
Under Unix this is usually the default shell âshâ. The value
returned is CMDâs exit status as returned by âwaitpidâ [...].
-- Scheme Procedure: system* arg1 arg2 ...
-- C Function: scm_system_star (args)
[...]
This function returns the exit status of the command as provided by
âwaitpidâ. This value can be handled with âstatus:exit-valâ and
the related functions.
[...]
And the documentation for "waitpid" says:
-- Scheme Procedure: waitpid pid [options]
-- C Function: scm_waitpid (pid, options)
[...]
The return value is a pair containing:
1. The process ID of the child process, or 0 if âWNOHANGâ was
specified and no process was collected.
2. The integer status value.
However, the return value doesn't appear to be a pair:
scheme@(guile-user)> (system "true")
$1 = 0
scheme@(guile-user)> (pair? $1)
$2 = #f
scheme@(guile-user)> (system* "true")
$3 = 0
scheme@(guile-user)> (pair? $3)
$4 = #f
scheme@(guile-user)>
In spite of this, the procedures like status:exit-val do seem to work as
expected:
scheme@(guile-user)> (status:exit-val $1)
$5 = 0
scheme@(guile-user)> (status:exit-val $3)
$6 = 0
Is the documentation incorrect? I checked the Guile source for the
system procedure, and it seemed to me like the documentation is
incorrect, but I'm not 100% sure, since I'm not very familiar with the
Guile source code, so I thought I'd ask here to make sure.
Thank you for your help!
--
Chris
Chris