At Fri, 20 Jul 2018 16:28:22 -0400, "'Leandro Facchinetti' via Racket Users" wrote: > Hi, > > I want to run a subprocess with a timeout. Here’s what I tried: > > #lang racket > (require racket/sandbox) > > (with-handlers ([exn:fail:resource? (λ (e) (displayln "Timed out"))]) > (with-limits 5 #f (system "sleep 10 && echo Finished"))) > > This doesn’t work, it prints both “Timed out” after 5 seconds and “Finished” > after 10 seconds. I wish ‘with-limits’ would stop the underlying process, so > I’d never see “Finished”. How should I do that?
You can use `current-subprocess-custodian-mode`: #lang racket (require racket/sandbox) (parameterize ([current-subprocess-custodian-mode 'kill]) (with-handlers ([exn:fail:resource? (λ (e) (displayln "Timed out"))]) (with-limits 5 #f (system "sleep 10 && echo Finished")))) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.