Re: [execline] [RFC] Allow `foreground` to handle signals
El dom, 27 jun 2021 a las 17:13, Laurent Bercot () escribió: > It sounds like your previous foreground process group (i.e. the > processes that launch your script) attempted to write to, or read from, > the terminal while your editor was running. That is pretty weird. > Replace -g with -f, see what happens. If your editor is stopped, just > remove the options entirely and run the editor in a new session; it > looks like your caller program is buggy. > That is indeed the problem: git output to console a message to tell you it's waiting for the editor to stop to commit. The fix was to: ``` foreground { s6-setsid -g editor ${file} } foreground { s6-setsid -g spellcheck ${file} } s6-setsid -g vcs-commit ${file} ```
Re: [execline] [RFC] Allow `foreground` to handle signals
Isn't job control the task of commands such as `foreground` and `background`? No, it's not. "foreground" means that the script waits for the process being spawned to exit before resuming; "background" means that the parent and the child execute in parallel. This has nothing to do with job control. Is your opinion that this modified foreground is outside the scope of execline, ant thus there should it be a toolset for job control? Yes, and maybe. Job control is out of scope of regular execline binaries, and I don't think that execline can bring much value over a shell when interactivity is involved, so I'm in no hurry to write a toolset for job control - but if you have worthwhile ideas for it, feel free to submit them. Thanks, this is half the answer, now the editor receives the signals, the other half of the answer is spwaning the next process when the editor exits. As of now, on the terminal one needs to use `fg` to continue the process. It sounds like your previous foreground process group (i.e. the processes that launch your script) attempted to write to, or read from, the terminal while your editor was running. That is pretty weird. Replace -g with -f, see what happens. If your editor is stopped, just remove the options entirely and run the editor in a new session; it looks like your caller program is buggy. -- Laurent
Re: [execline] [RFC] Allow `foreground` to handle signals
El dom, 27 jun 2021 a las 6:33, Laurent Bercot () escribió: > execline was not designed to handle interactive scripts: you need > some extra tooling in the presence of job control. > Isn't job control the task of commands such as `foreground` and `background`? Is your opinion that this modified foreground is outside the scope of execline, ant thus there should it be a toolset for job control? To achieve that, replace "foreground { editor ${file} }" with > "foreground { s6-setsid -g editor ${file} }". > Thanks, this is half the answer, now the editor receives the signals, the other half of the answer is spwaning the next process when the editor exits. As of now, on the terminal one needs to use `fg` to continue the process.
Re: [execline] [RFC] Allow `foreground` to handle signals
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