Open reox opened 5 years ago
and what if you just remove the .cuckoo/pidfiles/cuckoo.pid
?
obviously it works then... As a workaround you can put the pid files on a filesystem which is cleaned after a reboot. This solves the issue of a hard resetted PC.
But if cuckoo crashes and the PID file is not removed AND (the same PID is either attached to the new cuckoo process OR the PID was used in the meantime for a new process), cuckoo will not start.
Btw: cuckoo exists with an exit code of 0 in this case allthough the message indicates an error.
Same problem for the processing units:
Oct 16 13:15:41 cuckooc3 cuckoo[2012]: 2018-10-16 13:15:41,984 [cuckoo] ERROR: Cuckoo process instance 'processor_3' already exists. PID: 592
but:
ps -p 592
PID TTY TIME CMD
592 tty1 00:00:00 agetty
but the processing units exit with an exit code of 1 if they fail to start ;)
So i looked a little bit in the code and saw that cuckoo uses some custom Pidfile class: https://github.com/cuckoosandbox/cuckoo/blob/master/cuckoo/misc.py#L220 It just writes the pid into that file and compares it later. Why not use a file lock approach? As long as the file is locked by a process, this process is the only one, as all other processes are not able to lock the file. If the file can be locked by another process, this means that the old process has terminated.
Hi @reox
Thanks for posting an issue. :slightly_smiling_face:
Why not use a file lock approach?
This does sound like better approach. I will add it to the todo list, as the current approach can cause issues like in your case. I should probably have put a little more thought into it when adding this last year.
My issue is:
It looks like that cuckoo refuses to start if the old instance was killed but the new one get's the same PID or the PID is now used by another process:
In this case, both processes had PID 640 but the PID file is much older:
My Cuckoo version and operating system are:
2.0.6
This can be reproduced by:
You can test this by writing some existing PID into the pid file:
Testing the same PID is a little bit hard to do, as you would need to guess the PID of the cuckoo process beforehand.