SUMMARY: Question on why ps sometimes truncates the process name and puts it in brackets
Christopher Knorr <[email protected]>
| Newsgroups | gmane.os.tru64.managers |
|---|---|
| Message-ID | <[email protected]> |
Original Question: Why does the ps output sometimes truncate the process name and put it in brackets? Thanks to Dr. Blinn for the following thorough answer: The UNIX standard for the "ps" command allows the system to truncate or omit certain parts of the output when the resources necessary to gather and display them are unavailable. There are two places this could happen -- inside the "ps" utility and in the kernel (which is called MANY times by the utility to gather the data for a single "ps -e" command, especially if there are a lot of processes on the system). In this case, the output is usually being truncated in the kernel because there is a temporary shortage of the in-memory buffer size needed for that particular field. When that happens, you'll see the kind of output you're seeing. The correct fix for this is to design your script to be able to deal with either of the two outputs, since you will presumably always get one or the other. There may be ways to simplify the logic that would result in a more expeditious and reliable test, but you should be just fine if you take into account that as system load changes, there can be times when certain resources are temporarily scarce and that these times can impact the output of commands like "ps" (or for that matter, cause some things to simply fail).