chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Return value of `system'


From: Kon Lovett
Subject: Re: [Chicken-users] Return value of `system'
Date: Wed, 14 Mar 2007 19:23:41 -0700

On Mar 14, 2007, at 6:33 PM, Zbigniew wrote:

On 3/14/07, Kon Lovett <address@hidden> wrote:
Zbigniew wrote:
> Exit values should be distinguishable from signals (and even from
> signals+core dumps).

   return C_fix(WIFEXITED(n) ? WEXITSTATUS(n) : (WIFSIGNALED(n) ?
WTERMSIG(n) : WSTOPSIG(n)));

I don't always talk thru my hat ;-)

Don't worry, I would expect nothing less from you.  I figured you had
already checked the code and the return value might be munged.

Please, expect less. That way I can surprise. :-)


In my experience, on a UNIX box it is imperative that you get the full
range of information provided by system(), especially since Chicken's
intent is to be as practical as possible.  My opinion is that (system)
should return system()'s raw return value-- i.e. C_fix(n) --and that
accessor functions be provided to tease that information apart, along
the lines of the C macros.  Since (system) is in unit library and much
is deliberately left to the vagaries of the system, it may be more
acceptable to create a new function and accessors in Unit posix. (Or
in a separate egg so people don't need cutting-edge Chicken?)

Agreed, a better return value is needed.

(I could add a plain substitute for 'system' to the osprocess egg. A call that doesn't have the complexity of the current interface.)

What others do:

Chez Scheme 7 'system' returns "unspecified" - one way to get around the issue.
MzScheme 'system' returns a boolean.
Gambit-C 'shell-command' returns the C 'system' call return value.

For the library unit 'system' return value:

1) Store the return & exit status for the last call & provide accessors, as you suggested. Return the C 'system' call return value.

2) Multi-valued result, a'la 'process-wait'.

3) Return boolean value.

I kinda prefer #3. If the user needs more, use a more complicated interface. The posix unit 'process' & 'process*' already have a shell- command mode.

Best Wishes,
Kon





reply via email to

[Prev in Thread] Current Thread [Next in Thread]