Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Ctrl-C signal handler #123

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Set Ctrl-C signal handler #123

wants to merge 2 commits into from

Conversation

certik
Copy link
Collaborator

@certik certik commented Sep 13, 2024

This allows to catch Ctrl-C from within a running command, but unfortunately still exits. Also there seems to be some thread (?) still running in the background, since I get some later error message while I am already back in Bash:

~/repos/shell(ctrl_c2)$ cat
^CReceived Ctrl+C

~/repos/shell(ctrl_c2)$ cat: Input/output error (os error 5)
Error: Errno(EIO)

~/repos/shell(ctrl_c2)$

@certik
Copy link
Collaborator Author

certik commented Sep 13, 2024

On Windows on the other hand it does not exit the shell:

~/repos/shell(ctrl_c2)$ ../lfortran/src/bin/lfortran
Interactive Fortran. Experimental prototype, not ready for end users.
LFortran version: 0.40.0-57-gb50db1203
  * Use Ctrl-D to exit
  * Use Enter to submit
  * Use Alt-Enter or Ctrl-N to make a new line
    - Editing (Keys: Left, Right, Home, End, Backspace, Delete)
    - History (Keys: Up, Down)
>>> Received Ctrl+C                                                           1,1   ]
~/repos/shell(ctrl_c2)$

Although it leaves the terminal in a bad state (up arrow prints [A instead of showing the previous command), but that's a separate issue.

@certik
Copy link
Collaborator Author

certik commented Sep 20, 2024

On Linux with /bin/cat, it seems to work:

~/repos/shell(ctrl_c2)$ /bin/cat
s
s
^CReceived Ctrl+C
~/repos/shell(ctrl_c2)$

But on the builtin cat it just hangs, will not exit. I must exit it with Ctrl-D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant