DB / Linux / 3
WARNING

Linux SIGQUIT

SIGQUIT is a termination signal sent to a process, typically triggered by the user pressing Ctrl+\ or via the kill command. It causes the process to terminate and generate a core dump for debugging purposes.

Common Causes

  • User pressing Ctrl+\ in the terminal
  • Explicit kill command: kill -3 <PID> or kill -SIGQUIT <PID>
  • Process receiving SIGQUIT from another application or system component
  • Container runtime sending SIGQUIT before forceful termination

How to Fix

1 Check Process Status and Core Dumps

Verify if the process terminated and check for generated core dump files for debugging.

BASH
$ # Check process status ps aux | grep <process_name> # Look for core dump files (location may vary) ls -la /var/lib/systemd/coredump/ ls -la /tmp/ find / -name "core*" -type f 2>/dev/null | head -20

2 Configure Core Dump Settings

Ensure core dumps are enabled and properly configured to capture debugging information.

BASH
$ # Check current core dump limits ulimit -c # Set unlimited core dump size for current session ulimit -c unlimited # Permanent configuration in /etc/security/limits.conf # Add: * soft core unlimited # Or user-specific: username soft core unlimited

3 Debug with GDB Using Core Dump

Use GDB to analyze the core dump file and understand why the process received SIGQUIT.

BASH
$ # Debug with core dump gdb /path/to/executable /path/to/core.dump # Once in GDB, run these commands: # bt - show backtrace # info registers - show register values # info threads - show all threads # thread apply all bt - backtrace for all threads

4 Handle SIGQUIT in Application Code

Implement signal handlers in your application to gracefully handle SIGQUIT instead of terminating.

BASH
$ // C/C++ example signal handler #include <signal.h> #include <stdio.h> #include <stdlib.h> void sigquit_handler(int sig) { printf("Received SIGQUIT. Performing cleanup...\n"); // Perform cleanup operations fflush(stdout); exit(0); // Exit gracefully } int main() { signal(SIGQUIT, sigquit_handler); // Your application code here while(1) { // Main loop } return 0; }

5 Prevent Accidental Ctrl+\ Triggers

Configure terminal or shell to ignore or remap Ctrl+\ key combination.

BASH
$ # Disable Ctrl+\ in bash stty quit undef # Or remap to another key stty quit ^x # Change to Ctrl+x # Make permanent in ~/.bashrc echo 'stty quit undef' >> ~/.bashrc