Added Linux/processes page

This commit is contained in:
Dhaverd 2025-08-26 13:36:54 +08:00
parent eb557b89a1
commit c50f27d110
2 changed files with 42 additions and 0 deletions

41
Linux/processes.md Normal file
View File

@ -0,0 +1,41 @@
# Process interaction snippets
## Find process occupying port
```
ss -lptn 'sport = :5173'
```
### Output example:
```
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 511 [::1]:5173 [::]:* users:(("node",pid=29634,fd=32))
```
## Kill process
```
sudo kill -[signal] [PID]
```
### Example:
```
sudo kill -9 29634
```
### Signals:
- **SIGTERM (Signal 15).** This signal asks for a process to terminate. The process can capture this signal, perform cleanup operations, and then exit. By default, the kill command sends SIGTERM if no other signal is specified.
- **SIGKILL (Signal 9).** It forcefully kills a process. The process cannot capture or ignore this signal, which results in an immediate termination. It should be used as a last resort when a process doesnt respond to SIGTERM.
- **SIGINT (Signal 2).** This is typically sent when you press Ctrl + C in the terminal. It interrupts a process and is usually used to stop a process running in the foreground.
- **SIGHUP (Signal 1).** Sent to a process when its controlling terminal is closed and often used to reload configuration files.
- **SIGQUIT (Signal 3).** Causes a process to terminate and produce a core dump file for debugging.
- **SIGSTOP (Signal 19).** Pauses a process without killing it, similar to pressing Ctrl + Z in the terminal.
- **SIGCONT (Signal 18).** Continues a process that was stopped by SIGSTOP or Ctrl + Z.

View File

@ -9,6 +9,7 @@ This is a repository with useful snippets of various kinds of code
- - [common](./src/branch/master/Git/common.md)
- [Linux](./src/branch/master/Linux/)
- - [certbot_nginx](./src/branch/master/Linux/certbot_nginx.md)
- - [processes](./src/branch/master/Linux/processes.md)
- [MySQL](./src/branch/master/MySQL)
- - [all_foreign_keys_to_table_or_column](./src/branch/master/MySQL/all_foreign_keys_to_table_or_column.md)
- - [identify_lock](./src/branch/master/MySQL/identify_lock.md)