Skip to content

Commit 0b1e567

Browse files
committed
handle stop signal to be able restart process without breaking current jobs
1 parent dad137a commit 0b1e567

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### [29-02-2020]
2+
* SIGHUP handling to stop submitting tasks and stop cuckoo.py, useful for when you need to reload it without breaking running jobs
3+
* `ps aux|grep "python3 cuckoo.py"|cut -d" " -f 5| xargs kill -1`
4+
15
### [22-01-2020]
26
* Add qemu.py with support for x64/x86/MIPS/MIPSEL/ARM/ARMWRT/ARM64/PowerPC/PowerPC64/Sparc/Sparc64
37
* Basic linux integration is done thanks to @enzok

lib/cuckoo/core/scheduler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import gc
88
import time
99
import shutil
10+
import signal
1011
import logging
1112
import threading
1213
import queue
@@ -624,6 +625,10 @@ def __init__(self, maxcount=None):
624625
self.maxcount = maxcount
625626
self.total_analysis_count = 0
626627

628+
def set_stop_analyzing(self, signum, stack):
629+
self.running = False
630+
log.info("Now wait till all running tasks are completed")
631+
627632
def initialize(self):
628633
"""Initialize the machine manager."""
629634
global machinery, machine_lock
@@ -715,6 +720,9 @@ def start(self):
715720

716721
log.info("Waiting for analysis tasks.")
717722

723+
#To handle stop analyzing when we need to restart process without break tasks
724+
signal.signal(signal.SIGHUP, self.set_stop_analyzing)
725+
718726
# Message queue with threads to transmit exceptions (used as IPC).
719727
errors = queue.Queue()
720728

0 commit comments

Comments
 (0)