Re: Difficulty understanding pipe-exist-status documentation
Hi Martin,
Thanks a lot for the answer. For now, calling pipe-exit-status after close seems to work at least in Linux, which is our main target platform. The external process is third-party software which doesn’t have a quit command and will most likely not do what we want if we just kill it. So yes, some additional functionality in LispWorks to gracefully close the handles would be good, although it’s not urgent for our particular case.
Thanks,
Pascal
> On Jul 7, 2015, at 18:20, Martin Simmons <martin@lispworks.com> wrote:
>
>
> Hi Pascal,
>
> The second paragraph applies regardless of the value of wait.
>
> There is no way to close the stream gracefully and wait for the process to
> finish.
>
> If the child process has a "quit" command, then you could send that down the
> pipe.
>
> Otherwise, you can use system:pipe-kill-process to force it to die
> (http://www.lispworks.com/documentation/lw70/LW/html/lw-1319.htm).
>
> I.e. this sequence of calls should work:
>
> (setq pipe (sys:open-pipe ... :save-exit-status t))
> (system:pipe-kill-process pipe)
> (system:pipe-exit-status pipe :wait t)
> (close pipe)
>
> That may not help in your case though if you want the program to exit
> gracefully. We possibly need to add a function that causes eof in the program
> (i.e. closes the pipe handles in the stream) without closing the whole stream
> so that it can still be queried by pipe-exist-status.
>
> --
> Martin Simmons
> LispWorks Ltd
> http://www.lispworks.com/
>
>
>>>>>> On Fri, 3 Jul 2015 08:39:50 +0000, Costanza, Pascal said:
>>
>> Hi,
>>
>> I’m having some difficulty understanding the documentation for
>> pipe-exit-status, which is new in LispWorks 7.0.
>>
>> The documentation states:
>>
>> "If wait is t then pipe-exit-status waits until the child process dies.. If
>> wait is nil then pipe-exit-status does not wait, and if the child process is
>> still running it returns nil. The default value of wait is t.
>>
>> On Microsoft Windows, if close was called on the stream before the child
>> process died, then pipe-exit-status returns exit-status :closed. On
>> Unix-like systems it works after close but for compatibility it should be
>> called only before calling close.”
>>
>> Does the second paragraph about behavior specific to Microsoft Windows apply
>> both when wait is t or nil, or only when wait is nil?
>>
>> If it applies also when wait is t, how do I properly close a program and
>> wait for it to die?
>>
>> The use case is an external program with a pipe that accepts input from
>> LispWorks, but only finishes executing when that stream is closed. However,
>> the external program may lag behind, so it’s really important that I wait
>> until that program finishes before proceeding. In Unix, I would expect to be
>> able to just call close and then pipe-exit-status with :wait t on the
>> stream, but the documentation makes me doubt that’s portable. Unfortunately,
>> I can’t test this for Windows since I don’t have a LispWorks license for
>> Windows.
>>
>> Thanks a lot for comments in advance,
>> Pascal
>>
>> --
>> Pascal Costanza, ExaScience Lab Belgium, Intel Health & Life Sciences
>> pascal.costanza@intel.com
>>
>> Intel Corporation NV/SA
>> Kings Square, Veldkant 31
>> 2550 Kontich
>> RPM (Bruxelles) 0415.497.718.
>> Citibank, Brussels, account 570/1031255/09
>>
>> This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
>>
>> _______________________________________________
>> Lisp Hug - the mailing list for LispWorks users
>> lisp-hug@lispworks.com
>> http://www.lispworks.com/support/lisp-hug.html
>>
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>
--
Pascal Costanza, ExaScience Lab Belgium, Intel Health & Life Sciences
pascal.costanza@intel.com
Intel Corporation NV/SA
Kings Square, Veldkant 31
2550 Kontich
RPM (Bruxelles) 0415.497.718.
Citibank, Brussels, account 570/1031255/09
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html