Skip to content

Unable to detect running processes on Alpine-based system #38

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

Merged
merged 1 commit into from
May 7, 2018
Merged

Unable to detect running processes on Alpine-based system #38

merged 1 commit into from
May 7, 2018

Conversation

gregurco
Copy link
Contributor

The problem is that in alpine ps command ignores PID argument. So, when you run ps 1 you always will receive ALL processes. I added -o pid to command to remove useless data and to leave only PIDs and added one more condition to detect if process is running, so finally the process is running if:

  • the result of exec has more then 1 line
  • PID exists in result of ps command

Similar problem: inspec/inspec#2034

@gregurco
Copy link
Contributor Author

ping @Phobetor

@Phobetor
Copy link
Owner

Phobetor commented May 7, 2018

@gregurco Thanks for this particular fix. And thanks for the optimization in general. It is much more reliable, now. Even if the output format should change for some reason.

@Phobetor Phobetor merged commit 4da1201 into Phobetor:master May 7, 2018
@gregurco gregurco deleted the alpine_fix branch May 7, 2018 14:54
@Phobetor
Copy link
Owner

Hi @gregurco

Thank you very much again for this pull request!

It is merged to dev-master and released in version 3.0.0.

I had to fix the call to ps to make it run on ubuntu/debian. I changed it from

ps %d -o pid

to

ps -o pid %d

Can you please verify if this is also working on alpine?

Thanks in advance!

@gregurco
Copy link
Contributor Author

@Phobetor yep, it's working 🙂 👍

@Phobetor
Copy link
Owner

@gregurco great, thanks!

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