cmd icon indicating copy to clipboard operation
cmd copied to clipboard

Allow killing jobs on Lisp exit (job control?)

Open Ambrevar opened this issue 4 years ago • 2 comments

Currently, the following

> (cmd:cmd& "sleep 17")
#<UIOP/LAUNCH-PROGRAM::PROCESS-INFO {100DB4A553}>
("sleep" "17")
> ,quit

leaves the "sleep" process hanging in the background. It's particularly inconvenient if the process happens to consume a lot of CPU.

Job control can be complicated to implement, so maybe it's out of the scope of this library. Any idea if a Common Lisp job control library already exists?

That said, we could leverage the shell to do job control. For instance, the following will kill the sleep process when Lisp is exited:

 (uiop:launch-program "set -o monitor; sleep 17 & read dummy; kill %1" :input :stream)

The workaround has the benefit of being easy to implement (just need to make sure the command is passed properly to the same). The downside is that it runs a shell process for each launch-program.

Maybe make it (global) option of cmd? Thoughts?

Ambrevar avatar Jan 13 '21 11:01 Ambrevar

So far I've limited cmd to functionality that is available on Windows as well as Unix. Do you know of a Windows equivalent?

ruricolist avatar Jan 14 '21 23:01 ruricolist

I don't use Windows and I don't know it, sorry :/

That said, we could put a -windows feature macro that does the right-thing for non-Windows platforms. Note that this is all transparent to the user since I would not call this "functionality" per se, more an implementation detail.

Thoughts?

Ambrevar avatar Jan 15 '21 08:01 Ambrevar