WIP: readline: ctrl+c close stdin - #673
Conversation
|
@dirk-zimoch I wrote this code as I do not think I was explaining myself properly in the #671 thread. I am happy to leave this PR as an example. |
|
✅ Build EPICS Base 7 base-7.0-1782 completed (commit e976b22926 by @mdavidsaver) |
|
fyi. testing with modified ralphlange/procServ#70 with ./procServ -d -f --killsig 2 --grace-period 3 5678 ~/epics/base-git/bin/linux-x86_64/softIoc
...
epics> var atExitDebug 1Concurrent |
Provokes readline() and getc() to return immediately, and so also interrupts interactive iocsh(NULL) .
945bf0b to
8bbcabe
Compare
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| UnusedCode | 2 medium |
| Security | 1 high |
🟢 Metrics 6 complexity
Metric Results Complexity 6
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Rebased with no changes. My casual testing over the past year has not turned up any misbehavior. |
|
✅ Build EPICS Base 7 base-7.0-2379 completed (commit c3f7922ffa by @mdavidsaver) |
My attempt at #670. Provokes
readline()andgetc()to return immediately, and so also interrupts interactiveiocsh(NULL). Only interruptsiocsh(NULL), just as anexitiocsh command currently does. Depends on IOC skeleton toConsequential differences with #671.
epicsExit().close(0), usesdup2()to atomically replace stdin with/dev/nullto avoid potential race with re-use of FD zero.sigaction()to also save/restore handler flags.SA_RESETHANDhandler flag so that a repeated signal will trigger the default handler.Unnecessary differences, which could/should be removed.
A bunch of calls tofprintf()for troubleshooting, which is not signal-safe.iocsh(NULL)in a loop with multiple interruptions.dup2()to restore stdin loses FD flags. (could save/restore flags as well)SA_RESTARTflag to approximate BSD behavior. Maybe reduces testing matrix.SIGTERM.