2006-10-20 17:55:08 -04:00
|
|
|
IN: process
|
2006-10-21 01:54:24 -04:00
|
|
|
USING: compiler io io-internals kernel parser generic
|
|
|
|
sequences ;
|
2006-10-20 17:55:08 -04:00
|
|
|
|
|
|
|
LIBRARY: libc
|
|
|
|
FUNCTION: int system ( char* command ) ;
|
|
|
|
FUNCTION: void* popen ( char* command, char* type ) ;
|
|
|
|
FUNCTION: int pclose ( void* file ) ;
|
|
|
|
|
|
|
|
: run-process ( string -- ) system io-error ;
|
|
|
|
: run-detached ( string -- ) " &" append run-process ;
|
|
|
|
|
2006-10-21 01:54:24 -04:00
|
|
|
! Help me implement the equivalent feature on Windows, please...
|
|
|
|
|
2006-10-20 18:24:50 -04:00
|
|
|
TUPLE: process-stream pipe ;
|
|
|
|
|
|
|
|
C: process-stream ( command mode -- stream )
|
|
|
|
>r popen dup r>
|
|
|
|
[ set-process-stream-pipe ] keep
|
|
|
|
>r dup <duplex-c-stream> r>
|
|
|
|
[ set-delegate ] keep ;
|
|
|
|
|
|
|
|
M: process-stream stream-close
|
|
|
|
process-stream-pipe [ pclose drop ] when* ;
|
|
|
|
|
|
|
|
: !" parse-string system drop ; parsing
|