Re: [execline] [RFC] Allow `foreground` to handle signals

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Sun, 27 Jun 2021 11:33:04 +0000

>On bash, the editor receives ^C and ignores the signal properly.
>
>On execline, foreground receives ^C and closes the whole script,
>maybe causing me to lose the work done so far.

  execline was not designed to handle interactive scripts: you need
some extra tooling in the presence of job control.

  Your problem here is that you have an interactive program, editor,
that can receive job control commands while running in the same
process group as the whole script, so job control commands, which
send signals to the process group, affect the whole script instead of
just the editor process. You need to run editor in another process
group (or another session).

  To achieve that, replace "foreground { editor ${file} }" with
"foreground { setsid editor ${file} }".

  That will create a new session for editor to run in. If you have
s6 installed, you can also use s6-setsid -g instead - that will create
a new process group without creating a new session.

  Hope this helps,

--
  Laurent
Received on Sun Jun 27 2021 - 13:33:04 CEST

This archive was generated by hypermail 2.4.0 : Sun Jun 27 2021 - 13:33:36 CEST