From: Jim Newton
Subject: UNIX os stuff in lisp
Date: 
Message-ID: <304993F2rokhdU1@uni-berlin.de>
What do people recommend to execute unix programs from
within a lisp program.

I.e., how can i write a lisp function which calls
a named UNIX executable with a list of command line arguments,
and returns an object/data-structure/list which describe the
exit status, lines of stdout, lines of stderr, whether the
program dumped a core etc....


I'm mainly using CMUCL, and i've seen the page
http://common-lisp.net/project/cmucl/doc/cmu-user/unix.html#toc230
which appears fairly low level.  Do i have to write such a function
as i'm describing with these low level system calls.  Do i have to
handle forking myself and waiting and reaping the children?  Or is
there an easier way?

-jim

From: Edi Weitz
Subject: Re: UNIX os stuff in lisp
Date: 
Message-ID: <u65439ed5.fsf@agharta.de>
On Thu, 18 Nov 2004 19:51:47 +0100, Jim Newton <·····@rdrop.com> wrote:

> What do people recommend to execute unix programs from within a lisp
> program.
>
> I.e., how can i write a lisp function which calls a named UNIX
> executable with a list of command line arguments, and returns an
> object/data-structure/list which describe the exit status, lines of
> stdout, lines of stderr, whether the program dumped a core etc....
>
> I'm mainly using CMUCL, and i've seen the page
> http://common-lisp.net/project/cmucl/doc/cmu-user/unix.html#toc230
> which appears fairly low level.  Do i have to write such a function
> as i'm describing with these low level system calls.  Do i have to
> handle forking myself and waiting and reaping the children?  Or is
> there an easier way?

  <http://common-lisp.net/project/cmucl/doc/cmu-user/extensions.html#toc46>

Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Jim Newton
Subject: Re: UNIX os stuff in lisp
Date: 
Message-ID: <304a3jF2qeob0U1@uni-berlin.de>
hey that function sure beats the &^&* out of perl's "system"
function huh?

-jim

Edi Weitz wrote:
> On Thu, 18 Nov 2004 19:51:47 +0100, Jim Newton <·····@rdrop.com> wrote:
> 
> 
>>What do people recommend to execute unix programs from within a lisp
>>program.
>>
>>I.e., how can i write a lisp function which calls a named UNIX
>>executable with a list of command line arguments, and returns an
>>object/data-structure/list which describe the exit status, lines of
>>stdout, lines of stderr, whether the program dumped a core etc....
>>
>>I'm mainly using CMUCL, and i've seen the page
>>http://common-lisp.net/project/cmucl/doc/cmu-user/unix.html#toc230
>>which appears fairly low level.  Do i have to write such a function
>>as i'm describing with these low level system calls.  Do i have to
>>handle forking myself and waiting and reaping the children?  Or is
>>there an easier way?
> 
> 
>   <http://common-lisp.net/project/cmucl/doc/cmu-user/extensions.html#toc46>
> 
> Edi.
> 
From: Jim Newton
Subject: Re: UNIX os stuff in lisp
Date: 
Message-ID: <304ebmF2s45flU1@uni-berlin.de>
I'm taking a look at
<http://common-lisp.net/project/cmucl/doc/cmu-user/extensions.html#toc46>
and i have some questions about the :status-hook.
It is a function that gets called automatically when my child process's
status changes.  What happens if i have 100 child processes and many of
their statuses change at about the same time?  Do i need to worry
about this?   What if the status changes before i get finished
creating all my processes?  What if the status-hook function is
running, and before it finishes another processes status changes?
Do i need to implement a locking mechanism myself to handle this
situation?



-jim


Jim Newton wrote:
> hey that function sure beats the &^&* out of perl's "system"
> function huh?
> 
> -jim
> 
> Edi Weitz wrote:
> 
>> On Thu, 18 Nov 2004 19:51:47 +0100, Jim Newton <·····@rdrop.com> wrote:
>>
>>
>> <http://common-lisp.net/project/cmucl/doc/cmu-user/extensions.html#toc46>
>>
>> Edi.
>>
> 
From: Edi Weitz
Subject: Re: UNIX os stuff in lisp
Date: 
Message-ID: <u8y8y99rr.fsf@agharta.de>
On Thu, 18 Nov 2004 21:18:31 +0100, Jim Newton <·····@rdrop.com> wrote:

> I'm taking a look at
> <http://common-lisp.net/project/cmucl/doc/cmu-user/extensions.html#toc46>
> and i have some questions about the :status-hook.  It is a function
> that gets called automatically when my child process's status
> changes.  What happens if i have 100 child processes and many of
> their statuses change at about the same time?  Do i need to worry
> about this?  What if the status changes before i get finished
> creating all my processes?  What if the status-hook function is
> running, and before it finishes another processes status changes?
> Do i need to implement a locking mechanism myself to handle this
> situation?

That's most likely a question for the CMUCL mailing list.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Björn Lindberg
Subject: Re: UNIX os stuff in lisp
Date: 
Message-ID: <hcszn1f56la.fsf@my.nada.kth.se>
Hi Jim,

Jim Newton <·····@rdrop.com> writes:

> What do people recommend to execute unix programs from
> within a lisp program.
> 
> I.e., how can i write a lisp function which calls
> a named UNIX executable with a list of command line arguments,
> and returns an object/data-structure/list which describe the
> exit status, lines of stdout, lines of stderr, whether the
> program dumped a core etc....

ext:run-program does exactly this.


Bj�rn
From: Szymon
Subject: Re: UNIX os stuff in lisp
Date: 
Message-ID: <85mzxehmof.fsf@eva.rplacd.net>
Btw, I 'stole' some of your code: `WITH-OUTPUT-FROM-PROGRAM'.

http://lisp.jogger.pl/comment.php?eid=75590&startid=0

Regards, Szymon.