Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What was the process receiving ^C and exiting, was it bash itself ? if so, why do I have another prompt ? does every new line start a new bash process ?
void main(void)
{
printf("String for errno 130 is %s\n", strerror(130));
}
$ ~/testcode
$ ./test-err.exe
String for errno 130 is Too many processes
From my system errno.h file:
Code:
#define EPROCLIM 130
My terminal performs this to.
I'm sure there's some sort of explanation for it, but I'm only concerned when I need to parse the return error value from a bash call or a system call in my programs.
What was the process receiving ^C and exiting, was it bash itself ? if so, why do I have another prompt ? does every new line start a new bash process ?
CTRL-C is a signal only, you'll have to look up if it is SIG_INTERRUPT (sp) or SIG_KILL and then determine what the signal it causes will do to a normal shell terminal.
Since it is not logoff, your shell is not going to exit. The terminal shell is a program, written to pay attention to signals, or ignore them, or use the default behaviors assigned by the system. Recommend if you consider these to be pressing questions that you determine which shell and version you have, and seek out the source code for it, as well as research what signal CTRL-C gives to a process and determine if the shell program is processing that as part of it's source code or if it is using the system default. Then determine what, if any, system default for that signal is, it may be to ignore it.
looks like something was started in the background. Either from .bashrc, from PS1 or whatever....
FWIW I don't think anything's started in the background. A brand new shell terminal on my system does exactly this.
I see this on cygwin, Debian 10, Peppermint, and Mint 19.
You create a new terminal, echo $? you get 0.
Hit CTRL-C, echo $?, you get 130.
Once again I feel this just merits inspecting what the default system behavior is for that signal, and a determination as to what the shell program may do if given that signal.
FWIW I don't think anything's started in the background. A brand new shell terminal on my system does exactly this.
I see this on cygwin, Debian 10, Peppermint, and Mint 19.
You create a new terminal, echo $? you get 0.
Hit CTRL-C, echo $?, you get 130.
Once again I feel this just merits inspecting what the default system behavior is for that signal, and a determination as to what the shell program may do if given that signal.
in that case the interrupt handler itself is that (what was started).
An exit-code > 128 is usually the result of a signal. exit-code - 128 gives the signal number, in this case 2 (SIGINT).
ctrl-c from the tty triggers a sigint to be sent to the foreground process-group. If no process is being run at the time, then I would assume that foreground process is bash itself. I would also assume that bash traps the sigint and just sets $? to 130 instead of exiting.
An exit-code > 128 is usually the result of a signal. exit-code - 128 gives the signal number, in this case 2 (SIGINT).
ctrl-c from the tty triggers a sigint to be sent to the foreground process-group. If no process is being run at the time, then I would assume that foreground process is bash itself. I would also assume that bash traps the sigint and just sets $? to 130 instead of exiting.
For what it's worth I'm actully doing this via konsole which is a terminal application. I'm guessing it has the same behaviour as if I ran it from a tty ? (i.e ^C is sent to the bash not konsole)
As I understand it, it's actually done by the kernel's tty or pty driver (which terminal emulators all use), The terminal emulators only involvement is writing a ^C character to the pty.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.