@@ -269,6 +269,9 @@ $ (sleep 0.4 ; echo "a slow line" >> w/msg.log) &
269269$ fg %1 # byexample: +stop-on-silence=0.5
270270tail -f w/msg.log
271271a slow line
272+
273+ $ jobs
274+ [1]<...>Stopped<...>
272275` ` `
273276
274277> ** Note:** ` ` +stop-on-silence` ` requires the job control and monitoring to be
@@ -279,6 +282,10 @@ a slow line
279282> timeout. But in ` ` 8.0.0` ` this option was fixed and the old behaviour can
280283> be achieved using ` ` +stop-on-timeout` ` .
281284
285+ < ! --
286+ $ kill -9 $( jobs -p) && wait # byexample: -skip +pass
287+ -->
288+
282289# ## Stopping on timeout
283290
284291` ` +stop-on-silence` ` will stop a process if this one times out, which
@@ -326,6 +333,39 @@ $ cat - # byexample: +stop-on-silence +stop-signal=eof
326333
327334> * New* in ` ` byexample 10.1.0` ` .
328335
336+ Signals like ` SIGTERM` and ` SIGKILL` cannot be used from
337+ ` +stop-signal` ; the closest thing is the ` quit` signal (` SIGQUIT` or ` ^\` ):
338+
339+ ` ` ` shell
340+ $ cat - # byexample: +stop-on-silence +stop-signal=quit
341+ ` ` `
342+
343+ > * New* in ` ` byexample 10.5.2` ` .
344+
345+ # ## Arbitrary signals on stop
346+
347+ If you want to * kill* a process with ` SIGKILL` or ` SIGTERM`
348+ you will have to stop the process first with a ` suspend` signal (the
349+ default for ` +stop-signal` ), capture the process' id or job' s id and
350+ kill it calling ` kill` :
351+
352+ ` ` ` shell
353+ $ cat - # byexample: +stop-on-silence
354+
355+ $ # The following sends a SIGTERM. Replace the -15 by -9 to send
356+ $ # a SIGKILL. See signal(7).
357+ $ kill -15 %%
358+ < ...>
359+ ` ` `
360+
361+ In fact, you can use this trick to send any signal like ` SIGUSR1` .
362+ In some cases you will have to bring the process to foreground (with
363+ ` fg` to give it a chance to receive the signal).
364+
365+ ` ` ` shell
366+ $ fg # byexample: +pass
367+ ` ` `
368+
329369# # Using other shells
330370
331371` ` byexample` ` supports ` ` bash` ` , ` ` dash` ` and ` ` ksh` ` and the shell
@@ -378,7 +418,7 @@ Or you could run ``bash`` without the constraint to be POSIX-conformant
378418by default (but see ` set +o posix` as mentioned above before trying to do this):
379419
380420` ` ` shell
381- $ byexample -l shell -x-shebang ' shell:%e bash --norc --noprofile' test/ds/shell-example
421+ $ byexample -l shell -x-shebang ' shell:%e bash --norc --noprofile --noediting ' test/ds/shell-example
382422< ...>
383423[PASS] Pass: 14 Fail: 0 Skip: 0
384424` ` `
@@ -399,7 +439,7 @@ shell's specific options
399439 +stop-on-silence [secs]
400440 stop the process if no output is read in the last
401441 <secs> seconds (0.2 secs by default).
402- +stop-signal {suspend,eof,interrupt}
442+ +stop-signal {suspend,eof,interrupt,quit }
403443 signal to send when stop-on-timeout/stop-on-silence is
404444 used (suspend ^Z by default).
405445 +shell {bash,dash,ksh,sh}
0 commit comments