PRCTL(1)

๐Ÿ’– PRCTL(1) โ€” Process operations ๐Ÿ’–

okay bestie, so this is a page from the General Commands Manual, and it's literally all about the prctl command. sit down, grab a boba, we're doing process vibes today. ๐Ÿง‹โœจ


โœจ NAME โœจ

prctl โ€” process operations. that's it, that's the whole name. iconic behavior honestly. ๐Ÿ’…


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

prctl [-v] [-h|--help] [--version] <-q|<options....>> [command]

where <options> are:

--unaligned=[silent|signal|always-signal|default]

--fpemu=[silent|signal|default]

--mcekill=[early|late|default]

so yeah, you gotta pick your lane: either -q (just peek at the settings) or one or more of those options up there. no half-committing. ๐Ÿซถ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

prctl lets you query or control certain process behavior. supported options are:

Unaligned memory access: when a process does an unaligned memory access, the default is that the kernel emulates it correctly and logs the unaligned access in syslog. but like, you can change that. the kernel could emulate the unaligned access correctly without logging an error (silent), or it could send SIGBUS to the process (signal and always-signal). heads up: always-signal is available on ia64 only. ๐Ÿ‘‘

Floating point assistance faults: when a process hits a floating point assist fault, the kernel would invoke the floating point emulator and log the fault. you can flip that too โ€” the kernel could emulate the floating point operation without logging an error (silent), or send SIGFPE to the offending process (signal). ๐Ÿ˜ค

Machine check memory corruption kill policy: if a hardware memory corruption is detected inside a thread's address space, the memory corruption kill policy decides whether that thread gets SIGBUS the second the corruption is detected (early), when it actually accesses the corrupted memory (late), or just uses the system wide default. pick your fighter. ๐Ÿ”ฅ

prctl can optionally be followed by a command. if a command is specified, prctl will exec the command with the processor behavior set to whatever you asked for in the options. if there's no command, prctl will fork a new shell โ€” unless the command only queried the current settings. ๐Ÿš

the shell started by prctl is the one defined by the environment variable SHELL. if SHELL isn't defined, then the shell in the password entry for the user gets started. and if there's no shell in the password entry either? bash gets started. slay. โœจ

โญ OPTIONS โญ

  • -v โ€” verbose mode. in verbose mode, any new settings are confirmed with a message on stdout. it's giving receipts. ๐Ÿงพ
  • --help โ€” print usage information and exit. bestie just wants to read the instructions. ๐Ÿ“–
  • --version โ€” print software version and exit. ๐Ÿ‘‘
  • -q โ€” query the current settings for the process options controllable by prctl. the vibe check of options. ๐Ÿ”
  • --unaligned=[silent|signal|always-signal|default]] โ€” set unaligned memory access behavior to not log the access (silent), send SIGBUS to the process (signal), or do the default (default). on IA-64 architecture there's an extra value, always-signal, which causes a SIGBUS to be generated every single time an unaligned access occurs. for the deets on when an unaligned access would not generate a signal normally, refer to the section titled "Memory Datum Alignment and Atomicity" in "Intel IA-64 Architecture Software Developer's Manual: Volume 2". if you don't specify a value after =, the current setting is returned. no cap. ๐Ÿ“š
  • --fpemu=[silent|signal|default]] โ€” set floating point assist fault behavior to not log the fault (silent), send SIGFPE to the process (signal), or do the default (default). if no value is specified after =, the current setting is returned. ๐Ÿงฎ

if an option is specified multiple times, the last one takes effect. so don't fight yourself, the last word wins. periodt. ๐Ÿ’…


๐Ÿ’€ EXAMPLES ๐Ÿ’€

  • prctl --unaligned=signal starts up a shell (as defined by the environment variable SHELL) and sets up any process running under this shell to be sent SIGBUS upon an unaligned memory access. ๐Ÿ˜ญ
  • prctl --unaligned=signal gdb tst starts up a gdb session for the program "tst" with the process set to receive SIGBUS upon unaligned memory access. debug era. ๐Ÿ›
  • prctl --unaligned= displays the current setting for unaligned memory access handling. ๐Ÿ‘€
  • prctl --unaligned= gdb tst displays the current setting for unaligned memory access handling and starts up a gdb session for the program "tst". multitasking queen. ๐Ÿ‘‘

๐Ÿ™ˆ NOTES ๐Ÿ™ˆ

prctl works on 2.4.0 and above kernels only. old kernel? not me. ๐Ÿ’€

the --fpemu= option is specific to IPF (Itanium Processor Family, previously known as IA-64) and is supported on kernels 2.4.11 and above. other architectures and kernels may return an "Invalid argument" error. so like, know your architecture bestie. ๐Ÿฆ‹


๐ŸŒˆ SEE ALSO ๐ŸŒˆ


๐Ÿซถ AUTHOR ๐Ÿซถ

Khalid Aziz <khalid.aziz@oracle.com>


๐Ÿ’œ LICENSE ๐Ÿ’œ

this software is made available under the GNU General Public License (GPL) Version 2. this software comes with NO WARRANTY. read that again, fr fr. ๐Ÿ˜ค


okay so that's the whole page, we ate and left no crumbs. ๐Ÿ“ one last thing before you go: this is the prctl page, "Process operations", out of the General Commands Manual โ€” PRCTL(1) if you're being fancy. go set some process behavior, you main character. bye bestie! ๐ŸŽ€โœจ๐Ÿ’