Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread names are missing the last character because the CMD column is only 14 characters wide #321

Open
bas-k opened this issue Feb 12, 2025 · 0 comments

Comments

@bas-k
Copy link

bas-k commented Feb 12, 2025

According to the manpage of pthread_setname_np the maximum lenght of a thread ls:

The thread name is a
meaningful C language string, whose length is restricted to 16
characters, including the terminating null byte ('\0').

The CMD column in atop however has a width of 14 characters, which leads to the stripping of the last character from thread names.

char *
procprt_CMD_a(struct tstat *curstat, int avgval, int nsecs)
{
        static char buf[15];

        sprintf(buf, "%-14.14s", curstat->gen.name);
        return buf;
}

char *
procprt_CMD_e(struct tstat *curstat, int avgval, int nsecs)
{
        static char buf[15]="<";
        char        helpbuf[15];

        sprintf(helpbuf, "<%.12s>",  curstat->gen.name);
        sprintf(buf,     "%-14.14s", helpbuf);
        return buf;
}

detail_printdef procprt_CMD = 
   { "CMD           ", "CMD", procprt_CMD_a, procprt_CMD_e, ' ', 14};

This is a problem for us because we cannot see the difference between some threads that have similar names except for the last character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant