Search code examples
linuxshellembeddedembedded-linux

Askfirst in shell


I came across an error in an open source software called askfirst while working on a embedded device.

I know askfirst is used to run commands based on user input on stdin.

But when I press ctrl + \ during askfirst process (which is used to provide serial connection to device after booting up) it triggers a SIGQUIT to the process which generates a core dump file.

But in the askfirst handler file there is nothing related to the above mentioned shortcut.

I need to know why this core dump is generated and if there is a way to prevent it.


Solution

  • This isn't a feature (or bug) in askfirst. You can send SIGQUIT to any process running in a terminal by pressing Ctrl-\.

    It is, instead, a feature of the terminal. You can use stty -a to see which key presses generate which signals:

    $ stty -a
    speed 38400 baud; rows 24; columns 80; line = 0;
    intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
    ...
    

    There is some more detailed information about the exact mechanism in the answer to this question: In detail, what happens when you press Ctrl-C in a terminal? The same mechanisms apply to Ctrl-\.

    If you want to disable core dumps (in the current shell), you can use:

    $ ulimit -c 0
    

    If you wanted to have that happen every time you logged in, you could add that command to your ~/.profile file.