-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Close session without waiting for <Enter> if process terminates with SIGHUP or exit status 129 #94
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
Conversation
|
Thanks! Will look into this and try it out. |
Scripts can send themselves the SIGHUP signal ("Hangup"), e.g. using
"kill -HUP $$", to indicate that they want to close the session without
waiting for the user to press Return.
Fixes termux#56
|
rebased against current master |
|
Should I improve something in this pull request? For example, I could remove the (FWIW, no bugs so far in my daily usage.) |
|
@rustybird Sorry for the delay in feedback! I'm not sure what the best course of action is here. After talking with some people using the app, perhaps it's best just to close sessions automatically on exit code 0, and let everything else (other exit codes and signals) cause the current behaviour where Enter is needed to proceed. The rare case where someone messes up the startup (as in What do you (and others) think about that? |
|
To be honest, tapping enter just isn't that big of a deal. It might be worth skipping enter for ~/.shortcuts (perhaps a termux specific commandfor scripts) but again, I just don't find it that troublesome.. |
Sounds good to me, closing on exit status 0 is more intuitive than SIGHUP for sure. Should I push an updated commit?
Maybe a double tap (or some other gesture) on Termux widgets? |
|
Love termux but find having to press Enter after pressing ^D annoying. On any unix like system users can break their accounts with buggy init files and a dozen other ways, With termux there is no admin to save users from their mistakes but pretty much anything a user can do to screw up his environment (buggy .profile, .bashrc, etc) can be fixed by either clearing termux data or re-installing it. I would add an option in termux.properties to disable the prompt for Enter and advise users to periodically backup their work, maybe even provide a pair of scripts to do backup/restore to/from shared storage. The restore script could also rename termux.properties as additional protection. |
|
I think the best approach would be an option in tasker that can be switched on/off by the user. Maybe a check box in the long-press menu? If the user's profile is somehow corrupted or messed up, it can always be fixed by editing the files using another app or adb. |
|
I agree that if your just casually using termux pressing enter is no big deal. I am not however. I have it as an ssh server itself and a remote task starter for my server at home. Using the .shortcut folder and widgets. I have a large list of shortcuts and I often have to press a few. Since it can't be closed programmatically I either have to: Sheltering noobs is fine. But not at the expense of encumbering those who could easily fix simple problems like a bad .bashrc config. I think any solution to this would make this already versatile and fantastic app much better. IMO The seperate failsafe shortcut idea sounds the most noob friendly. |
|
Maybe this should be configurable in the |
|
@fornwall any resolution on this? |
|
With a little searching I found that Exit status 129 (128+1) means you got
HUP kill signal for your session, that means either you got low ram or it
maybe your android os (I'd like to know whos os version are you on)
PS:This maybe incorrect....
|
|
Just found out you can put items in ~/.shortcuts/tasks/ and then they won't open the terminal at all. Awesome! |
|
@alexlance is right. No more enter spamming! yey! Thanks for sharing :-) The shortcut widget prefixes the shortcut with task/ so some of my shortcut names are a little truncated. And the Termux window doesn't show at all so any info you might want to display while the shortcut is running will need to be changed to toasts. Really happy with this regardless. Would still like to have the window show with a no enter needed option as well though. For long messages toasts aren't ideal. |
|
Further tested the .shortcut/tasks method - since termux doesn't show at all any script that needs user input via read command or similar won't work. Just realized when testing my home light control script which runs a script on my server via ssh and has a menu using the read command. So still stuck with press enter in this case. |
There's always ways to break things. |
|
Very good point. I was also going to suggest a separate failsafe shortcut, or some way to start the app in "failsafe" mode. Also i'd like to point out that the majority of termux users will be using a rooted device, so in this case it's always possible to remove the offending/broken script without losing any other data. So the "broken beyond repair" argument really only applies to the small minority of non-rooted ROM's or devices, which tbh i don't understand why such users would be using termux in the first place. Plus, waiting for Enter before closing the window/session just shows you (in some cases) what's going on, and doesn't really accomplish anything in terms of fixing it. |
|
@delt01 the waiting for enter enables you to open the left drawer and open a failsafe session by long-pressing "new session", so it at least enables you to fix the problem (without root). As a side note, I think termux has lots of uses even without root. I seldom use root even though my devices are rooted. |
|
I'm closing this. Anyone still interested: Feel free to take the code, rebase it on master again, and open a new pull request. |
See #56 (comment)
I added the exit status 129 check because Marshmallow /system/bin/sh seems to violate http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html#tag_20_117_09 (by catching the signal and acting as if the last child process had received it).
Fixes #56