diff options
author | Clayton Smith <argilo@gmail.com> | 2020-10-29 21:43:59 -0400 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2020-10-30 14:33:00 +0100 |
commit | babc17e616d01c09d281a59fbbf780961b372b39 (patch) | |
tree | 596872ce625e3886c5dd172e82958fb22c5a1e01 /gnuradio-runtime/python/gnuradio | |
parent | a95cece077c4687a25f030895a151836f6d7ec29 (diff) |
Remove gru.daemonize and dial_tone_daemon example
These were added in GNU Radio 3.1.3, but a Google search finds no
mention of gru.daemonize outside of the changelog. Modern Python
programs could use the python-daemon library, which implements the
daemon specification of PEP 3143.
Diffstat (limited to 'gnuradio-runtime/python/gnuradio')
-rw-r--r-- | gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-runtime/python/gnuradio/gru/__init__.py | 1 | ||||
-rw-r--r-- | gnuradio-runtime/python/gnuradio/gru/daemon.py | 92 |
3 files changed, 0 insertions, 94 deletions
diff --git a/gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt index d2e8c442d7..a122da0930 100644 --- a/gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt +++ b/gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt @@ -10,6 +10,5 @@ include(GrPython) GR_PYTHON_INSTALL(FILES __init__.py msgq_runner.py - daemon.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/gru ) diff --git a/gnuradio-runtime/python/gnuradio/gru/__init__.py b/gnuradio-runtime/python/gnuradio/gru/__init__.py index 97f4889e37..8443f1a4fd 100644 --- a/gnuradio-runtime/python/gnuradio/gru/__init__.py +++ b/gnuradio-runtime/python/gnuradio/gru/__init__.py @@ -1,5 +1,4 @@ # make this a package # Import gru stuff -from .daemon import * from .msgq_runner import * diff --git a/gnuradio-runtime/python/gnuradio/gru/daemon.py b/gnuradio-runtime/python/gnuradio/gru/daemon.py deleted file mode 100644 index b4c927dfe4..0000000000 --- a/gnuradio-runtime/python/gnuradio/gru/daemon.py +++ /dev/null @@ -1,92 +0,0 @@ -# -# Copyright 2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# SPDX-License-Identifier: GPL-3.0-or-later -# -# - - -import os, sys, signal - -# Turn application into a background daemon process. -# -# When this function returns: -# -# 1) The calling process is disconnected from its controlling terminal -# and will not exit when the controlling session exits -# 2) If a pidfile name is provided, it is created and the new pid is -# written into it. -# 3) If a logfile name is provided, it is opened and stdout/stderr are -# redirected to it. -# 4) The process current working directory is changed to '/' to avoid -# pinning any filesystem mounts. -# 5) The process umask is set to 0111. -# -# The return value is the new pid. -# -# To create GNU Radio applications that operate as daemons, add a call to this -# function after all initialization but just before calling gr.top_block.run() -# or .start(). -# -# Daemonized GNU Radio applications may be stopped by sending them a -# SIGINT, SIGKILL, or SIGTERM, e.g., using 'kill pid' from the command line. -# -# If your application uses gr.top_block.run(), the flowgraph will be stopped -# and the function will return. You should allow your daemon program to exit -# at this point. -# -# If your application uses gr.top_block.start(), you are responsible for hooking -# the Python signal handler (see 'signal' module) and calling gr.top_block.stop() -# on your top block, and otherwise causing your daemon process to exit. -# - -def daemonize(pidfile=None, logfile=None): - # fork() into background - try: - pid = os.fork() - except OSError as e: - raise Exception("%s [%d]" % (e.strerror, e.errno)) - - if pid == 0: # First child of first fork() - # Become session leader of new session - os.setsid() - - # fork() into background again - try: - pid = os.fork() - except OSError as e: - raise Exception("%s [%d]" % (e.strerror, e.errno)) - - if pid != 0: - os._exit(0) # Second child of second fork() - - else: # Second child of first fork() - os._exit(0) - - os.umask(0o111) - - # Write pid - pid = os.getpid() - if pidfile is not None: - open(pidfile, 'w').write('%d\n'%pid) - - # Redirect streams - if logfile is not None: - lf = open(logfile, 'a+') - sys.stdout = lf - sys.stderr = lf - - # Prevent pinning any filesystem mounts - os.chdir('/') - - # Tell caller what pid to send future signals to - return pid - -if __name__ == "__main__": - import time - daemonize() - print("Hello, world, from daemon process.") - time.sleep(20) - print("Goodbye, world, from daemon process.") |