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

Fix read error cmdline #151

Closed
wants to merge 2 commits into from
Closed

Conversation

duanyao
Copy link

@duanyao duanyao commented Mar 3, 2018

This PR follows #150 .

std::strerror(errno));
std::exit(3);
return NULL;
return false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 much more graceful :)

@@ -151,9 +142,21 @@ void setnode(unsigned long inode, pid_t pid) {
prg_node *newnode = new prg_node;
newnode->inode = inode;
newnode->pid = pid;
newnode->cmdline = getcmdline(pid);
bool result = getcmdline(pid, newnode->cmdline);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should split this into 2 parameters (one for the program and one for the parameters) already here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay.
If the caller needs all the details, newnode->cmdline need to be of type vector<string> , because there may be spaces in an parameter.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this right, newnode->cmdline is now populated with a string containing the program name, then a \0, and then all parameters (with spaces).

That seems kind of odd. I was proposing returning 2 strings instead, one for the program name and one for the parameters (with spaces), removing the funny business with the \0 character. WDYT?

@raboof
Copy link
Owner

raboof commented Apr 20, 2020

(closing due to inactivity, feel free to reopen when resuming work on this)

@raboof raboof closed this Apr 20, 2020
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

Successfully merging this pull request may close these issues.

2 participants