If I run mysqld from the command line, it displays some startup messages, and then stops responding. It doesn't produce output, and ignores any input, and there seems to be no way to get rid of it. ctrl+z and ctrl+c don't do anything, there is no way to get back to a terminal - I have to start a new session. This means, for instance, if I am connecting to a server via ssh I have to initiate a new ssh connection.This is very annoying. Is there any way in bash to tell it to deactivate the currently running process? Any other program I can suspend with ctrl+z, but not mysqld, though I don't know why. If I start it with mysqld & then it runs in the background and I can send signals to it normally, as long as I don't make the mistake of typing fg, and it otherwise acts like an ordinary process, so I don't know why ctrl+z has no effect on it, since I thought that was part of bash rather than being under the control of the process.So: Is there an alternative to ctrl+z, for when ctrl+z does not work?
How to interrupt uninterruptible program?
bash;keyboard shortcuts;background process;interrupt
Ctrl+Z is actually a feature of the generic terminal interface in the kernel, not of bash. It causes a SIGTSTP signal to be sent to the foreground process. Likewise Ctrl+C sends SIGTERM and Ctrl+\ sends SIGQUIT.There are two ways in which a program can cause Ctrl+Z to lose its effect.The program can ignore the SIGTSTP signal.You can check the a process's signal behavior with a debugger. On Linux, the information is available via /proc: grep Sig /proc/1234/status where 1234 is the process ID shows which signals are ignored (SigIgn, they'll just bounced off harmlessly) or blocked (SigBlk, they're put in wait until the program lets them in). The number is a bitmask and written out in hexadecimal. SIGTSTP is signal 20 (run kill -l in bash) so it is ignored if on the SigIgn line, the fifth digit from the right is 8 or above.The program can change the key bindings.You can check the current key bindings with a command line like stty -a </dev/pts/42 where /dev/pts/42 is the terminal where the process is running. Look for susp = ^Z.A daemon is likely to ignore most signals. Launch it in the background, if it doesn't fork by itself (most daemons actually fork a child as soon as they start and let the parent immediately). If you launched it in the foreground, there are many ways to recover (send it or its parent shell a signal) but you'll need another shell for that.