shell() in a separate thread with callback message at exit?

Joel Guillod joel.guillod at net2000.ch
Thu Mar 8 06:20:44 EST 2007


How can I implement the following features:

- invoque a shell command in a separate thread, i.e. a non blocking  
shell during execution of the command;
- receive a callback message with the output and the error result  
when the thread exits?

This would be some function similar to the load command, i.e.:

    shellExecute commandLine [with message callbackMessage]

where
   The commandLine is a string or an expression that evaluates to a  
string.
   The callbackMessage is the name of a message to send after the  
shell exited.

The callbackMessage signature would be:

   on <callbackMessage> pCmdOutput,pCmdError,pShellError

where
   - pCmdOutput is the value returned by the shell function, i.e. the  
result of the sdtout commandLine, including any error messages the  
commandLine generates.
   - pCmdError is the error the command generate (sdterr under unix).
   - pShellError is the shell command's exit code.


If I remember well the externals API allows for such threading and  
callback but I am not a C expert. Could anyone give me refs/pointers  
to a solution? I need a multiplatform solution.

Thanks a lot !  Joël





More information about the use-livecode mailing list