From: Luca Pisati

Subject: Re: Run-shell-command, timeout and multiprocessing

Date: 2000-12-18 15:37

Raimondas Kiveris wrote:
> > I have following problem: > > I have to use run-shell-command in a multithreaded application. > Run-shell-command with :wait t apparently suspends all other > threads and if external process takes significant time to complete > the whole application practically hangs. > > What I am looking for is a way to apply timeout to run-shell-command. > > mp:with-timeout unfortunately does not work: > > USER(33): (time (mp:with-timeout (2 :timed-out) (excl:run-shell-command > "sleep 10"))) > ; cpu time (non-gc) 0 msec user, 0 msec system > ; cpu time (gc) 0 msec user, 0 msec system > ; cpu time (total) 0 msec user, 0 msec system
> >>> ; real time 10,035 msec <<<
> ; space allocation: > ; 100 cons cells, 0 symbols, 0 other bytes, 0 static bytes > :TIMED-OUT > > Tried this with ACL 5 and 6 on Linux and Solaris. > > Any suggestions? > > rkv
Yes. You have to write your own wait loop. If you invoke run-shell-command with wait nil you will get back a PID. Then you can loop waiting for the process to finish. In the timed-out body you have to put some form that would send a sigkill to the process you are waiting for. It is a little tricky, since you should/could monitor for your spawned process to terminate or to be signaled. For this matter, we actually implemented our own wait function, that returns not only the termination of the spawned process, but also how the process terminated. The implementation of this "augmented" wait function would be OS dependent. -- Luca Pisati Director, Software Development Voice: (310) 578-7622 Ext. 550 Winged Edge Technologies Fax: (310) 578-7632 1042 Princeton Drive EMail: <wingededge.com at mailto:pisati> Marina Del Rey, CA 90292 Web: http://www.wingedegde.com