Linux Processes
- List threads:
ps -p <pid> -L
- environment variables in a process:
[rhel7tpcc-hub]cat /proc/29640/environ | tr '\0' '\n' | grep COBPATH
COBPATH=/home/hub/pkg_260324_es/lib/es
- pstree:
- See child processes:
pstree -pa
(see also/proc/<parent-pid>/task/
)
- See child processes:
- Redirecting to stdout and stderr:
- script:
echo "hello world stdout"
echo "hello world stderr" >&2
echo "hello world tty" >/dev/tty
- script:
- shared memory:
- signals:
- https://www-uxsup.csx.cam.ac.uk/courses/moved.Building/signals.pdf
- SIGABRT (6): The program called the abort() function. This is an emergency stop.
- SIGSEGV (11): An attempt was made to access memory not allocated to the process. This is often caused by reading off the end of arrays etc.
- strace:
- Follow child processes (-ff), capture child process output in separate files (-o), and don’t truncate the strings (-v -s 1024):
strace -v -s 1024 -o test -ff casstart /rTPCCDBFH /uSYSAD /pSYSAD
See also: https://www.thegeekstuff.com/2011/11/strace-examples/
- Follow child processes (-ff), capture child process output in separate files (-o), and don’t truncate the strings (-v -s 1024):
- sysctl (configure kernel parameters at runtime):
- Updating /etc/sysctl.conf:
- Use
sysctl -a
to get the full name. - Add the new value to
/etc/sysctl.d/99-custom.conf
(Note: On my system, this is a symbolic link to/etc/sysctl.conf
). - Reboot (alternatively, to avoid the reboot for now, run:
sysctl -p /etc/sysctl.d/99-custom.conf
).
- Use
- Updating /etc/sysctl.conf:
- UID/GID of running process:
cat /proc/<PID>/status (the first two values are real and then effective id)
Uid: 0 0 0 0
Gid: 1 1 1 1
- ulimit:
- Soft and Hard limits:
# ulimit -u -S
# ulimit -u -H
- Nice examples (from Oracle install)
- General procedure: edit
/etc/security/limits.conf
(and/or files in/etc/security/limits.d
) and then runsysctl -p
- Names of common items to change
- Check used network socket counts using lsof:
[nwb-tpccrh76es2-hub]asroot lsof -a -U -uhub |wc -l
17
[nwb-tpccrh76es2-hub]for i in {1..1000}; do curl localhost:8222/esmac/casrdo00 >nul 2>&1; done
[nwb-tpccrh76es2-hub]asroot lsof -a -U -uhub |wc -l
- Soft and Hard limits:
- gdb:
- Attach:
gdb -p <pid>
- List threads:
(gdb) info threads
- Switch to thread:
(gdb) thread <num>
- Show strack trac:
(gdb) backtrace
- Attach:
Written on October 13, 2020