Skip to content

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

@bas-k

Description

@bas-k

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions