GithubHelp home page GithubHelp logo

Can't start killed process about daemons HOT 7 CLOSED

kevinconway avatar kevinconway commented on August 21, 2024
Can't start killed process

from daemons.

Comments (7)

kevinconway avatar kevinconway commented on August 21, 2024

What signal did you use to kill the process?

from daemons.

coffebar avatar coffebar commented on August 21, 2024

SIGKILL

from daemons.

kevinconway avatar kevinconway commented on August 21, 2024

Ah, yeah. SIGKILL terminates the process without allowing it to run the cleanup logic. It's a known shortcoming of using signal trapping to perform pidfile cleanup. I think something like psutils would be a good alternative. I'm trying to keep the project dependency free so I will likely make psutils an optional driver for pid management.

Is using SIGKILL a requirement for your project? If not you should consider using another signal such as SIGTERM as it will properly tigger the cleanup logic and remove the pidfile.

from daemons.

coffebar avatar coffebar commented on August 21, 2024

Ah, yeah. SIGKILL terminates the process without allowing it to run the cleanup logic

it's not a secret

I'm trying to keep the project dependency free so I will likely make psutils an optional driver for pid management.

it would be great

Is using SIGKILL a requirement for your project?

I think that this is possible as the external impact

from daemons.

tenortim avatar tenortim commented on August 21, 2024

The problem isn't just if the daemon is killed. The same issue happens if it dies unexpectedly. Or the host system crashes or loses power. Or any number of other possibilities. That is why full pidfile handling needs to test that the pid is valid.

I need to test portability of the method, but on POSIX systems, there is no need for external dependencies. It's as easy as something like

try:
    os.kill(pid, 0)
except OSError as e:
    if e.errno == errno.EPERM:
        print("pid %d is running under a different username" % pid)
    elif e.errno != errno.ESRCH:
        print("kill of pid %d failed with error %s" % (pid, e.strerror))
    else:
        print("pid %d is running" % pid)

Windows supports os.kill in 2.7 onwards. I'll see if it works there.

from daemons.

tenortim avatar tenortim commented on August 21, 2024

The code as it stands doesn't work on Windows for a number of unrelated reasons.
The signal handling needs SIGQUIT removed since it doesn't exist on Windows (trivial), but then daemonize fails because os.fork doesn't exist either.

As such, I already have a fix (plus tests) for the pidfile handling in my clone. I'll submit a pull request.

from daemons.

kevinconway avatar kevinconway commented on August 21, 2024

Thanks to @tenortim I can finally close this bug!

from daemons.

Related Issues (6)

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.