I just checked in a Process.run() in 7.7:
http://pike.ida.liu.se/development/cvs/diff.xml?module=Pike&file=7.7/lib...
The rational for that is that I was once again reminded by a user this week that getting Process.create_process() or Process.Process right without some corner case blocking is hard. It's not obvious that if you bind pipes to booth stderr and stdout you have to take in to account that OS buffers are not limetless.
Process.run() is a thin wrapper around Process.Process that collects stdout, stderr and exitcode and return them in a mapping. This could potentially result in huge strings, but will do what most users want and even already do when they call create_process() with both pipes bound.
Something like this should be in 7.8, but I'm open to suggestions for other things that might be usefull to return in the mapping or for changing member names.
On Sun, Feb 12, 2006 at 01:25:06PM +0000, Peter Bortas (nu med mindre Opera) @ Pike (-) developers forum wrote:
Process.run() is a thin wrapper around Process.Process that collects stdout, stderr and exitcode and return them in a mapping. This could potentially result in huge strings, but will do what most users want and even already do when they call create_process() with both pipes bound.
could this also take a string as argument which is to be sent to stdin?
i thought about something similar (ie, an easier interface), but instead of just returning strings it would be taking callback functions as arguments that and then internally set up the stdout, stderr pipes with those callbacks. the returned process object would have a write() function, and all the buffer magic would be handled internally. yours is much easier for most people though.
greetings, martin.
Hm. A string|Stdio.File|function stdin parameter, setup magic handled by Process.run, would be nice. Perhaps way more brain scratching than you're up to to get done right though.
I guess modifiers->stdin could be extended to string|Stdio.File instead of just Stdio.File, but do you have a usecase for this? I'm not convinced that this makes things easier and less confused.
If anyone has a some free time a Process.Expect would be very nice. I had a go at one two years ago but never got it to work properly with applications that require setsid like yppasswd.
On Mon, Feb 13, 2006 at 06:45:11PM +0000, Peter Bortas (nu med mindre Opera) @ Pike (-) developers forum wrote:
I guess modifiers->stdin could be extended to string|Stdio.File instead of just Stdio.File, but do you have a usecase for this? I'm not convinced that this makes things easier and less confused.
is almost all cases i have the data i want to send to an external process locally available as a string. (if i had it in a file, i'd be writing a shell script) i could work around Stdio.File by using FakeFile, but string is generally easier.
the usecase is that, i use pike to process most of the data, and only occasionally need to use an external process to handle stuff. what the external process gets to work with i want to control from within pike.
greetings, martin.
Process.run now coverts modifiers->stdin to a working pipe if you feed it a string.
very nice! i have been trying to work on that but somehow could not figure out how todo it. thank you!
greetings, martin.
pike-devel@lists.lysator.liu.se