glidernet / ogn-rf

This software listens to OGN radio messages and sends it to Open Glider Network.
GNU General Public License v3.0
18 stars 15 forks source link

Version 0.2.5 crashs with SEGV if invoked by systemd #11

Open kerel-fs opened 8 years ago

kerel-fs commented 8 years ago

ogn-rf and ogn-decode crashes with SEGV or exits when stdin is redirected from /dev/null. This redirection is done by default by systemd for simple services.

Steps to repoduce

Download and install rtlsdr-ogn-0.2.5.ARM, then execute it with

./ogn-rf /etc/rtlsdr-ogn/site.conf < /dev/null

Alternatively, there is an ansible role to reproduces the issue with systemd involved: ogn-node

Initial log (systemd involved): http://paste.debian.net/hidden/b0f487a3/ Minimal failing scenario:

ogn@collin:/opt/rtlsdr-ogn-0.2.5 $ ./ogn-rf /etc/rtlsdr-ogn/site.conf < /dev/null 
HTTP_Server.Exec() ... Start
HTTP_Server.Exec() ... Listening on port 8080
Found Rafael Micro R820T tuner
Exact sample rate is: 1000000.026491 Hz
RTLSDR::Open(0,868300000,1000000) => Generic RTL2832U OEM,  868.300 MHz, 1.000 Msps
RTLSDR::Gain[29] =  +0.0  +0.9  +1.4  +2.7  +3.7  +7.7  +8.7 +12.5 +14.4 +15.7 +16.6 +19.7 +20.7 +22.9 +25.4 +28.0 +29.7 +32.8 +33.8 +36.4 +37.2 +38.6 +40.2 +42.1 +43.4 +43.9 +44.5 +48.0 +49.6 [dB]
RF_Acq.Exec() ... Half time slot
ogn@collin:/opt/rtlsdr-ogn-0.2.5 $
kerel-fs commented 8 years ago

I propose to add a command-line argument allowing ogn-rf and ogn-decode to run non-interactive, perhaps even as a proper daemon (--daemon/-d: Runs process in the background).

kerel-fs commented 8 years ago

Possible fix

Detect whether stdin is a terminal or a pipe and only try to read from stdin if it's a terminal. see also: SO: Detect if stdin is a terminal or pipe in C/C++/Qt?

csindle commented 7 years ago

Also affects version 0.2.6.

saedelman commented 5 years ago

This works for me. I use tty20 for ogn-rf and tty21 for ogn-decode.

[Service]
Type=simple
WorkingDirectory=/home/pi/rtlsdr-ogn
ExecStart=/home/pi/rtlsdr-ogn/ogn-rf /home/pi/rtlsdr-ogn/ogn.conf
KillMode=process
StandardInput=tty-force
TTYVHangup=yes
TTYPath=/dev/tty20
TTYReset=yes
Restart=always
RestartSec=10
KillSignal=SIGKILL
rvt commented 1 year ago

Perhaps late in the game, from docker I can run it with:

setsid sh -c 'exec ./ogn-rf Station.conf <> /dev/tty20'
ssozonoff commented 1 month ago

Interesting. I am experiencing the same things with s6 overlay so will try what @rvt mentioned to see if that works.