Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.2.5 crashs with SEGV if invoked by systemd #11

Open
kerel-fs opened this issue Sep 2, 2016 · 5 comments
Open

Version 0.2.5 crashs with SEGV if invoked by systemd #11

kerel-fs opened this issue Sep 2, 2016 · 5 comments

Comments

@kerel-fs
Copy link
Contributor

kerel-fs commented Sep 2, 2016

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
Copy link
Contributor Author

kerel-fs commented Sep 2, 2016

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
Copy link
Contributor Author

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?

kerel-fs added a commit to kerel-fs/ogn-rf that referenced this issue Feb 10, 2017
Fixes glidernet#11: Version 0.2.5 crashs with SEGV if invoked by systemd.
kerel-fs added a commit to kerel-fs/ogn-rf that referenced this issue Feb 16, 2017
Fixes glidernet#11: Version 0.2.5 crashs with SEGV if invoked by systemd.
kerel-fs added a commit to kerel-fs/ogn-rf that referenced this issue Feb 19, 2017
This is a workaround for glidernet#11: Version 0.2.5 crashs with SEGV if invoked by systemd,
since ogn-decode exits when it gets an EOF via stdin.
kerel-fs added a commit to kerel-fs/ogn-rf that referenced this issue Mar 15, 2017
This is a workaround for glidernet#11: Version 0.2.5 crashs with SEGV if invoked by systemd,
since ogn-decode exits when it gets an EOF via stdin.
@csindle
Copy link

csindle commented Sep 7, 2017

Also affects version 0.2.6.

@saedelman
Copy link

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
Copy link

rvt commented Feb 15, 2023

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

setsid sh -c 'exec ./ogn-rf Station.conf <> /dev/tty20'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants