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

Grepping for running ssh process has potential for false positives #2

Open
dicato opened this issue Sep 15, 2011 · 2 comments
Open

Comments

@dicato
Copy link
Owner

dicato commented Sep 15, 2011

This is because ps -elf truncates the command that is running. This can be fixed by writing and reading a PID file.

@younicksguy69
Copy link

In a shell script you can use this to get the PID file.

ssh -l username server -N
PID="$!"
echo $PID > $PIDFILE

This way you can check the PIDFILE and if that process exists you can check to see if it is an ssh process and if so you can be reasonably sure that it is your process.

@dicato
Copy link
Owner Author

dicato commented Sep 15, 2011

Apparently you can call .pid on the result of Popen. So writing x.pid to file for reading later should work.

@dicato dicato closed this as completed Sep 15, 2011
@dicato dicato reopened this Sep 15, 2011
@github-staff github-staff deleted a comment from mehdi-dev97 May 27, 2024
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

2 participants