-
Notifications
You must be signed in to change notification settings - Fork 1
fetch comm of pids and support outputing it #3
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
base: granulate
Are you sure you want to change the base?
Conversation
| goto error; | ||
| } | ||
|
|
||
| fread_res = getline(&line, &line_len, f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't initialize line before reading?
And why use a complicated API like getline when you just gotta read 16 bytes?
| log_error("Couldn't read %s file - errno %d\n", proc_fs_path, pid); | ||
| goto error; | ||
| } | ||
| comm_len = (size_t) fread_res - 1; /* remove \n delimiter */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle the 0 case so you don't underflow
|
|
||
| /* Force null termination */ | ||
| if (comm_len >= buf_size) { | ||
| buf[buf_size] = '\0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| buf[buf_size] = '\0'; | |
| buf[buf_size - 1] = '\0'; |
| } | ||
|
|
||
| strncpy(buf, "UNKNOWN-COMM", buf_size); | ||
| buf[buf_size] = '\0'; /* terminate just in case because strncpy doesn't */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.