Giter VIP home page Giter VIP logo

Comments (2)

mej avatar mej commented on August 20, 2024

Thanks for your report, Walter!

The code is correct as written. The kill command in bash returns 0 on success, yes, but success in this case doesn't mean the process went away. It simply means that the signal was successfully delivered to the process(es) specified. From the bash(1) man page:

kill returns true if at least one signal was successfully sent, or false if an error occurs or an invalid option is encountered.

In particular, "successfully sent" means that there was a process with the specified PID which was able to receive the signal. A non-zero return value, for our purposes, means that the specified process is no longer there to receive the signal -- i.e., it's already been successfully killed.

NHC uses the || return 0 you noted in the code to handle the case where either the process went away on its own, or NHC's previous attempt(s) to terminate it were successful, so it doesn't need to continue trying to kill (i.e., signal) it. If the invocation of kill succeeds, then the process is still there, so NHC might not have successfully gotten it to die yet and must therefore keep trying. Just because kill returns success doesn't mean the process actually died, though. It only means that the signal was delivered.

Make sense?

from nhc.

walterdejong avatar walterdejong commented on August 20, 2024

Yes, so true.

Thanks!

On Wed, Mar 30, 2016 at 8:50 PM, Michael Jennings [email protected]
wrote:

Thanks for your report, Walter!

The code is correct as written. The kill command in bash returns 0 on
success, yes, but success in this case doesn't mean the process went away.
It simply means that the signal was successfully delivered to the
process(es) specified. From the bash(1) man page:

kill returns true if at least one signal was successfully sent, or false if an error occurs or an invalid option is encountered.

In particular, "successfully sent" means that there was a process with the
specified PID which was able to receive the signal. A non-zero return
value, for our purposes, means that the specified process is no longer
there to receive the signal -- i.e., it's already been successfully killed.

NHC uses the || return 0 you noted in the code to handle the case where
either the process went away on its own, or NHC's previous attempt(s) to
terminate it were successful, so it doesn't need to continue trying to
kill (i.e., signal) it. If the invocation of kill succeeds, then the
process is still there, so NHC might not have successfully gotten it to die
yet and must therefore keep trying. Just because kill returns success
doesn't mean the process actually died, though. It only means that the
signal was delivered.

Make sense?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#13 (comment)


If a woodchuck could chuck wood, and a woodchuck would chuck wood,
how much wood would a woodchuck chuck?

from nhc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.