On Fri, Nov 10, 2023 at 4:22 PM Matthew Chae <[email protected]> wrote:
> Hi Denys,
>
> I'm sending the patch what I've mentioned. Can you take a look at this?
> If I don't understand correctly what you said before, let me know.
> > The max PID value can have 7 digits as the 4194304.
> > Busybox v1.36 released a new patch to handle large PID value in top command.
> > However, it still causes misalignment between the title and the number for
> > 7 digits or 6 digits PID.
> > The presence of a large number of PID and PPID digits in the column may
> > cause overflow, making it impossible to display the entire data accurately.
> > Plus, the large PID causes that user name can't be displayed up to 8
> > characters and result in the truncation of less than 8 characters.
> >
> > I can contribute new patch which allocates appropriate space for the number
> > of digits in the PID and PPID to represent the values in each column
> > correctly.
> > This can make alignment between the title and the number for 7 digits PID
> > and 5 digits PID and also display user name up to 8 characters.
> >
> > What do you think? If you agree, I will send a patch.
>
> Absolutely, please send a patch. Would be interesting to see a good solution.
+ fp = xfopen_for_read("/proc/sys/kernel/pid_max");
+ if (!fgets(pid_buf, PID_DIGITS_MAX + 1, fp)) {
...
+ if (strncmp(pid_buf, "32768", 5) == 0)
+ pid_digits_num = 5;
+ else
+ pid_digits_num = PID_DIGITS_MAX;
The logic above is not sound. Even if sysctl kernel.pid_max
is 32768, there can be already running processes with pids > 99999.
Ideally, the code should handle any pids correctly.
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox