This has nothing to do with foreground and background processes; it only has to do with the currently running process. When the kernel has to answer the question “What does /proc/self point to?”, it simply picks the currently-scheduled pid, i.e. the currently running process (on the current logical CPU). The effect is that /proc/self always points to the asking program's pid; if you run

ls -l /proc/self

you'll see ls's pid, if you write code which uses /proc/self that code will see its own pid, etc.

Answer from Stephen Kitt on Stack Exchange
🌐
Clever Uptime
cleveruptime.com › docs › files › proc-self
/proc/self: Explanation & Insights - CleverUptime
Overall, /proc/self provides a way for a process to access information about itself and its environment, which can be useful for debugging, performance monitoring, and other system-level tasks.
🌐
X
x.com › _JohnHammond › status › 1318545091489824769
John Hammond on X: "Don't forget about the /proc/ portion of the Linux filesystem, especially the /proc/self/ directory which refers to the currently running application. /proc/self/cmdline can be used to get an idea of how the program was invoked (and potentially see source code location). https://t.co/ekW7lE1hdr" / X
Don't forget about the /proc/ portion of the Linux filesystem, especially the /proc/self/ directory which refers to the currently running application. /proc/self/cmdline can be used to get an idea of how the program was invoked (and potentially see source code location).
🌐
Substack
fernandovillalba.substack.com › the personable engineer › a journey into the linux proc filesystem
A journey into the Linux proc filesystem
March 17, 2024 - Above we used $$ which returns the pid of the shell. So the above command gave us information about out current shell. One may be distracted and think that this is the same: ... /proc/self —> /proc/[process-accessing-id] (self will dynamically change location to point to the pid of the process accessing it)
🌐
Linux Man Pages
man7.org › linux › man-pages › man5 › proc.5.html
proc(5) - Linux manual page
/proc/thread-self See proc_thread-self(5). When a thread accesses this magic symbolic link, it resolves to the process's own /proc/self/task/tid directory. /proc/[a-z]* Various other files and subdirectories under /proc expose system-wide information. See also: proc_apm(5) proc_buddyinfo(5) proc_bus(5) proc_cgroups(5) proc_cmdline(5) proc_config.gz(5) proc_cpuinfo(5) proc_crypto(5) proc_devices(5) proc_diskstats(5) proc_dma(5) proc_driver(5) proc_execdomains(5) proc_fb(5) proc_filesystems(5) proc_fs(5) proc_ide(5) proc_interrupts(5) proc_iomem(5) proc_ioports(5) proc_kallsyms(5) proc_kcore(5)
🌐
Group-IB
group-ib.com › home › hiding in plain sight: techniques and defenses against `/proc` filesystem manipulation in linux
Linux `/proc` filesystem manipulation: Techniques and defenses | Group-IB
September 11, 2025 - /proc/cmdline: Provides the boot options passed to the kernel. /proc/loadavg: Contains statistics about the system’s load average over the last minutes. /proc/meminfo: Summarizes how the kernel is managing its memory.
Find elsewhere
🌐
The Linux Kernel
docs.kernel.org › filesystems › proc.html
The /proc Filesystem — The Linux Kernel documentation
The directory /proc contains (among other things) one subdirectory for each process running on the system, which is named after the process ID (PID). The link ‘self’ points to the process reading the file system.
🌐
TecMint
tecmint.com › home › linux commands › how to use /proc file system to monitor linux system
How to Use /proc File System to Monitor Linux System
January 25, 2024 - /proc/self – A symbolic link to the process’s own directory. /proc/stat – Contains a variety of statistics about the system, such as the number of processes running, the number of interrupts, and the amount of time spent in each CPU state. /proc/uptime – Contains the amount of time the system has been running. /proc/PID – Contains information about a specific process, where PID is the process ID.
🌐
Wordpress
peniwize.wordpress.com › 2011 › 04 › 08 › how-to-get-the-command-line-for-any-process-in-linux
Peniwize's Weblog | Just another WordPress.com weblog
April 8, 2011 - Posted by peniwize in Philosophy, Software Development on November 17, 2013 · This is a rant. I’m irritated
🌐
Linux Man Pages
man7.org › linux › man-pages › man5 › proc_pid_cmdline.5.html
proc_pid_cmdline(5) - Linux manual page
For processes which are still running, the command-line arguments appear in this file in the same layout as they do in process memory: If the process is well-behaved, it is a set of strings separated by null bytes ('\0'), with a further null byte after the last string. This is the common case, but processes have the freedom to override the memory region and break assumptions about the contents or format of the /proc/pid/cmdline file.
🌐
Red Hat
bugzilla.redhat.com › show_bug.cgi
88047 – /proc/<pid>/cmdline is empty in RHL8
Red Hat Bugzilla – Bug 88047 · This site requires JavaScript to be enabled to function correctly, please enable it · Privacy Contact FAQ Legal