Re: [Chicken-users] Can't get exit values of (process...)?
On Jan 17, 2007, at 11:54 PM, felix winkelmann wrote: On 1/17/07, Kon Lovett <[EMAIL PROTECTED]> wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, You can also try the "osprocess" egg. It will capture the exit status when the ports are closed. Needs a current Chicken though, >= 2.513 Kon, would it be possible to isolate the code for `process' (which you modified) into a separately compiled file/egg that provides the needed functionality for Robin, on a pre 2.513 chicken? I'm afraid I will forget something. Yes, but it will take a couple of days. I have other issues unfortunately. cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
On 1/17/07, Zbigniew <[EMAIL PROTECTED]> wrote: But you might have more success arguing that "process" should not ever invoke a wait() call when you close its ports, and instead leave that up to the user. Since you receive the PID from "process", you can process-wait on it, and retrieve the error code yourself. This way, process does the dirty work of setting up and tearing down a new process and bi-directional pipes, while you can do the easy work of wait(). What do people think? Should the wait() be removed from process? I think it shouldn't. The exit-status is a weak mechanism of communicating with the calling instance. Requiring a waitpid will just end up in unreaped child processes. If osprocess provides all the necessary things, users should prefer that for special requirements. cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
On 1/17/07, Kon Lovett <[EMAIL PROTECTED]> wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, You can also try the "osprocess" egg. It will capture the exit status when the ports are closed. Needs a current Chicken though, >= 2.513 Kon, would it be possible to isolate the code for `process' (which you modified) into a separately compiled file/egg that provides the needed functionality for Robin, on a pre 2.513 chicken? I'm afraid I will forget something. cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
On 1/17/07, John Cowan <[EMAIL PROTECTED]> wrote: > What do people think? Should the wait() be removed from process? Yes, I'd say so; it's not hard to insert a call to "wait" right after closing the input port. Note that Perl behaves this way w/r/t bi-directional pipes as well, requiring an explicit waitpid after the open2() call, for what it's worth. It also recommends you be very careful with open2() and to consider using a pty instead. I received a reply off-list (perhaps unintentionally so) suggesting a wait? parameter be added to process to avoid manually calling wait(). I think that's exactly what osprocess is for, though. Automatic waiting is present for unidirectional pipes because it makes clear semantic sense. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
Zbigniew scripsit: > But you might have more success arguing that "process" should not ever > invoke a wait() call when you close its ports, and instead leave that > up to the user. Since you receive the PID from "process", you can > process-wait on it, and retrieve the error code yourself. This way, > process does the dirty work of setting up and tearing down a new > process and bi-directional pipes, while you can do the easy work of > wait(). Furthermore, this makes for a sensible approach to disposition. You get three values back from "process", two ports and a PID. It's up to you to close each port and wait on the PID in order to properly dispose of everything. > What do people think? Should the wait() be removed from process? Yes, I'd say so; it's not hard to insert a call to "wait" right after closing the input port. -- John Cowan [EMAIL PROTECTED]http://ccil.org/~cowan Big as a house, much bigger than a house, it looked to [Sam], a grey-clad moving hill. Fear and wonder, maybe, enlarged him in the hobbit's eyes, but the Mumak of Harad was indeed a beast of vast bulk, and the like of him does not walk now in Middle-earth; his kin that live still in latter days are but memories of his girth and his majesty. --"Of Herbs and Stewed Rabbit" ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
I would agree with Kon on this---osprocess should work and give you more options. To me the overall problem is that opening both a read and write pipe to a process contains a bit of magic, and is not as easy as one might suppose. For example, many times you are better opening a pseudo tty, although your case seems not to require it. "process" just won't handle all the permutations you might want even if you start hacking on it, and eventually it would become osprocess. Let's take a step back. Normally, you open a unidirectional pipe and then grab the exit status via close-input-pipe or close-output-pipe -- the close will do a waitpid() for you and return the exit code. For a bi-directional pipe, should you return the PID when closing the input side, or the output side, or when the last one is closed? It is not clear. Additionally, as currently implemented, the bi-directional pipes are custom ports, which (from my admittedly cursory reading of the code) cannot return a value via close-input-port or close-output-port. The return value is unspecified, as noted in R5RS. Now, you might argue that custom ports should be able to return a value via close, and this value (for ports returned by "process") should be the exit code of the process. It looks to me like this could be done with just a bit of hacking. But you might have more success arguing that "process" should not ever invoke a wait() call when you close its ports, and instead leave that up to the user. Since you receive the PID from "process", you can process-wait on it, and retrieve the error code yourself. This way, process does the dirty work of setting up and tearing down a new process and bi-directional pipes, while you can do the easy work of wait(). What do people think? Should the wait() be removed from process? I myself think the point is moot, because I avoid bi-directional pipes at all costs. :) On 1/17/07, Kon Lovett <[EMAIL PROTECTED]> wrote: You can also try the "osprocess" egg. It will capture the exit status when the ports are closed. Needs a current Chicken though, >= 2.513 ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, You can also try the "osprocess" egg. It will capture the exit status when the ports are closed. Needs a current Chicken though, >= 2.513 Best Wishes, Kon -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Darwin) iEYEARECAAYFAkWugMkACgkQJJNoeGe+5O4nDQCfQWRACVtr/JOv+nVPRmvurXAW xkIAn0WL6/BbGb4fedJ07tze9RCgAXfR =YoNM -END PGP SIGNATURE- ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
On Wed, Jan 17, 2007 at 01:45:03PM -0600, Zbigniew wrote: > Robin, > > Did you try using process-fork to create the process, as Felix > suggested? The process can't "end" until you actually call > process-wait. *hangs head* You know, I knew that, I really did. I'll give it a shot. I the meantime, I'd still love to have process somehow return the exit value; where to I send feature requests? :D -Robin -- http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/ Reason #237 To Learn Lojban: "Homonyms: Their Grate!" Proud Supporter of the Singularity Institute - http://singinst.org/ ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
Robin, Did you try using process-fork to create the process, as Felix suggested? The process can't "end" until you actually call process-wait. In fact, you normally should call process-wait to properly reap your children. If you are noticing your children are being reaped automatically on your system, without calling wait(), you could try ensuring SIGCHLD is set to SIG_DFL (default signal handler) and not SIG_IGN, which may cause automatic reaping on some systems. I personally find the Perl documentation to be a nice quick reference for IPC issues. On 1/17/07, Robin Lee Powell <[EMAIL PROTECTED]> wrote: On Wed, Jan 17, 2007 at 11:26:27AM +0100, felix winkelmann wrote: > On 1/17/07, Robin Lee Powell <[EMAIL PROTECTED]> wrote: > >On Sun, Jan 14, 2007 at 09:53:00PM -0800, Robin Lee Powell wrote: > >> > >> The only way I see to get the exit value of something I call > >> with (process...) is to use (process-wait), but as I mentioned > >> in another mail, this errors out my entire program if the > >> process is already finished, so I can't see any way to do all > >> of the following: > >> > > If you start a subprocess with `process', the waitpid(2) is done > by closing the input and output port returned. If you want to get > at the exit-status, you should try to start a process via more > primitive functions, like `process-fork'. There a `process-wait' > gives you all necessary information (and the error can be caught > using `handle-exceptions'). To get at stdin/out, one can use the > usual fork/dup/exec dance to obtain file-descriptors (albeit in > Scheme using the functionality in the posix unit). The problem is, the programs I'm calling tend to complete the instant I gather their output. If the program is gone by the time I call process-wait, I don't get the exit status, so this really doesn't help me. I'm looking for something like the shell's $? here. Can I maybe hack process to do that? ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
On Wed, Jan 17, 2007 at 11:26:27AM +0100, felix winkelmann wrote: > On 1/17/07, Robin Lee Powell <[EMAIL PROTECTED]> wrote: > >On Sun, Jan 14, 2007 at 09:53:00PM -0800, Robin Lee Powell wrote: > >> > >> The only way I see to get the exit value of something I call > >> with (process...) is to use (process-wait), but as I mentioned > >> in another mail, this errors out my entire program if the > >> process is already finished, so I can't see any way to do all > >> of the following: > >> > > If you start a subprocess with `process', the waitpid(2) is done > by closing the input and output port returned. If you want to get > at the exit-status, you should try to start a process via more > primitive functions, like `process-fork'. There a `process-wait' > gives you all necessary information (and the error can be caught > using `handle-exceptions'). To get at stdin/out, one can use the > usual fork/dup/exec dance to obtain file-descriptors (albeit in > Scheme using the functionality in the posix unit). The problem is, the programs I'm calling tend to complete the instant I gather their output. If the program is gone by the time I call process-wait, I don't get the exit status, so this really doesn't help me. I'm looking for something like the shell's $? here. Can I maybe hack process to do that? -Robin -- http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/ Reason #237 To Learn Lojban: "Homonyms: Their Grate!" Proud Supporter of the Singularity Institute - http://singinst.org/ ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
On 1/17/07, Robin Lee Powell <[EMAIL PROTECTED]> wrote: On Sun, Jan 14, 2007 at 09:53:00PM -0800, Robin Lee Powell wrote: > > The only way I see to get the exit value of something I call with > (process...) is to use (process-wait), but as I mentioned in another > mail, this errors out my entire program if the process is already > finished, so I can't see any way to do all of the following: > If you start a subprocess with `process', the waitpid(2) is done by closing the input and output port returned. If you want to get at the exit-status, you should try to start a process via more primitive functions, like `process-fork'. There a `process-wait' gives you all necessary information (and the error can be caught using `handle-exceptions'). To get at stdin/out, one can use the usual fork/dup/exec dance to obtain file-descriptors (albeit in Scheme using the functionality in the posix unit). cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Can't get exit values of (process...)?
On Sun, Jan 14, 2007 at 09:53:00PM -0800, Robin Lee Powell wrote: > > The only way I see to get the exit value of something I call with > (process...) is to use (process-wait), but as I mentioned in another > mail, this errors out my entire program if the process is already > finished, so I can't see any way to do all of the following: > > 1. Call process > > 2. Read and write data with the new process > > 3. Get the new process's exit value, regardless of when during > step 2 it exited. > > Suggestions? The more I work with this code, the more important this is becoming. Even if I could get process-wait to not error out, it wouldn't give me the exit value if the child process is already finished. Help? -Robin -- http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/ Reason #237 To Learn Lojban: "Homonyms: Their Grate!" Proud Supporter of the Singularity Institute - http://singinst.org/ ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users