When I run a process and the content of argv[0], this also changes the content of /proc//cmdline. Now I checked in the kernel code in fs/proc/cmdline.c, and the cmdline_proc_show function there seems to get its content from the global saved_command_line variable. However I didn't find how saved_command_line is related to the argv array. Does anybody know that?
Asked
Active
Viewed 468 times
1 Answers
1
The file /proc/cmdline
relates to a kernel command line and info from boot_params
.
For user processes there are cmdline
files in subdirs named with a process-id /proc/<pid>/cmdline
; shell example: cat /proc/$$/cmdline
. A series of struct pointers leads to process command line args; for details see proc_pid_cmdline_read()
note: some symbols may differ between releases

Milag
- 1,793
- 2
- 9
- 8
-
2Ah right, so cmdline_proc_show in fs/proc/cmdline.c handles /proc/cmdline, whereas proc_pid_cmdline in fs/proc/base.c handles /proc/
/cmdline. And that simply accesses the argv variables in the process' virtual memory. Awesome, thanks a lot! – pottea Aug 17 '20 at 07:58