How do I increase the /proc/pid/cmdline 4096 byte limit?
You can't change this dynamically, the limit is hard-coded in the kernel to PAGE_SIZE in fs/proc/base.c:
274 int res = 0;
275 unsigned int len;
276 struct mm_struct *mm = get_task_mm(task);
277 if (!mm)
278 goto out;
279 if (!mm->arg_end)
280 goto out_mm; /* Shh! No looking before we're done */
281
282 len = mm->arg_end - mm->arg_start;
283
284 if (len > PAGE_SIZE)
285 len = PAGE_SIZE;
286
287 res = access_process_vm(task, mm->arg_start, buffer, len, 0);
PID hash table entries: 4096 (order: 12, 32768 bytes)?
PID hash table entries allocated as 2^N struct hlist_head
s, which on a 64bit system are 8 bytes each. 2^12*8 = 32768
.
Inode/Dentry caches are allocated as 2^N pages, usually 4096 bytes each. 2^15*4096 = 134217728
.
This info is available in the source, kernel/pid.c
and fs/inode.c
respectively.
OCaml file I/O: why is add_channel returning empty content for /proc/ PID /cmdline?
The first version doesn't work because /proc/<PID>/cmdline
(as well as any other file in the procfs
virtual file system) is not a regular file, and in_channel_length
(** Return the size (number of characters) of the regular file .. *)
You may notice, for example, that a file
or du
also think that the cmdline file is empty:
$ file /proc/1/cmdline
/proc/1/cmdline: empty
$ du -h /proc/1/cmdline
0 /proc/1/cmdline
Your first function will not always work on other non-regular files, for example on pipes.
How to get the command line args passed to a running process on unix/linux systems?
There are several options:
ps -fp <pid>
cat /proc/<pid>/cmdline | sed -e "s/\x00/ /g"; echo
There is more info in /proc/<pid>
on Linux, just have a look.
On other Unixes things might be different. The ps
command will work everywhere, the /proc
stuff is OS specific. For example on AIX there is no cmdline
in /proc
.
Related Topics
Position of a String Within a String Using Linux Shell Script
Could Not Load Shared Library Symbols for Linux-Vdso.So.1. While Debugging
Linux Command Output as a Parameter of Another Command
Shell Function to Tail a Log File for a Specific String for a Specific Time
Webpack --Watch Exits After Building Once
"Cannot Execute Binary File" When Trying to Run a Shell Script on Linux
How to Install Ssreflect and Mathcomp in Linux
How to Embed Version Information into Shared Library and Binary
Executing Script on Receiving Incoming Connection with Xinetd
Sed: -I May Not Be Used with Stdin on MAC Os X
Can't Run Sonar Server Caused by Elasticsearch Cannot Running as Root
Find String Inside a Gzipped File in a Folder
Postgresql on Elastic Beanstalk (Amazon Linux 2)
What Does -Prune Option in Find Do
Fork() Failing with Out of Memory Error
Use Crontab Job Send Mail, the Email Text Turns to an Attached File Which Named Att00001.Bin