[Gambas-user] shell and exec with wait

Benoit Minisini gambas at ...1...
Thu Mar 17 10:54:37 CET 2005


On Wednesday 16 March 2005 18:08, Rob wrote:
> On Wednesday 16 March 2005 11:56, José María Lucero wrote:
> > I am having problems using shell and exec comands with Wait For
> > Read, it seems to ignore the wait.
>
> There's no such thing as SHELL ... WAIT FOR READ or
> EXEC [ ... ] WAIT FOR READ.  WAIT and FOR READ are mutually
> exclusive... currently, any output generated by a program executed
> with WAIT is discarded.  If you want to run a program synchronously
> and retrieve its output, look at workarounds such as my "Backtick"
> function which is in the wiki and Gambas help.
>
> I actually think specifying WAIT and FOR READ together should throw a
> compile-time error... I'm going to update the wiki to reflect their
> mutual incompatibility.
>
> Rob
>
>

The reason for this mutual incompatibility is the following:

To wait for the end of a process, the interpreter calls the sigsuspend() 
function, that sleeps until a signal comes. As the event loop is based on the 
select() call, it is not managed during the sleep().

What I need is a system call that do select() AND sigsuspend() at the same 
time, but it does not exist in Linux. It is just emulated by the GNU libc: 
its name is pselect().

I can use it, but you must know that when you use a graphical toolkit library, 
like QT or GTK+, it must manage the event loop itself. Alas, at least in QT, 
only select() is called, and so I can't wait for a process by calling their 
event loop: it can never return, even if the process is terminated.

In Qt, the signal handler that is raised when a process is terminated 
(SIGCHLD) writes to a socket, so that an event can be generated in the event 
loop.

I think I can use the same trick. I must see... But the right way is having 
the pselect() system call in Linux :-)

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list