Discussion:
[Hamlib-developer] How to stop the `rigctld` daemon?
Serge Stroobandt
2017-01-23 17:14:25 UTC
Permalink
Hi folks!

Here is what my sound like a trivial question:

After having launched the `rigctld` daemon in the background,
how do I stop it?

Reading the documentation, I cannot find anything about stopping `rigctld`.
It would be handy to have an inherent `rigctld` command for that.

73 de Serge, ON4AA
http://hamwaves.com/propagation/
Nate Bargmann
2017-01-24 12:16:38 UTC
Permalink
Post by Serge Stroobandt
Hi folks!
After having launched the `rigctld` daemon in the background,
how do I stop it?
Typically from the terminal it was launched from use Ctl-C. When the
PID is known the 'kill PID' command works. There is also the 'killall
rigctld' command.
Post by Serge Stroobandt
Reading the documentation, I cannot find anything about stopping `rigctld`.
It would be handy to have an inherent `rigctld` command for that.
Perhaps that is something to look into.

73, Nate
--
"The optimist proclaims that we live in the best of all
possible worlds. The pessimist fears this is true."

Ham radio, Linux, bikes, and more: http://www.n0nb.us
Ervin Hegedüs
2017-01-24 12:18:05 UTC
Permalink
Hi Serge,
Post by Serge Stroobandt
Hi folks!
After having launched the `rigctld` daemon in the background,
how do I stop it?
how do you start the rigctld in background? Do you use the "&"
sign at the end of the cmdline?

If yes, you can see the running jobs with "jobs" command. To take
foreground a process, you can use cmd "fg".

$ rigctld -m 1 &
[1] 31109
$ jobs
[1]+ Running rigctld -m 1 &
$ fg
rigctld -m 1

at this point, you can press the CTRL+C, and rigctld will exit.


73, Ervin
HA2OS
Serge Stroobandt
2017-01-25 15:19:46 UTC
Permalink
Post by Serge Stroobandt
Hi folks!
After having launched the `rigctld` daemon in the background,
how do I stop it?
Thanks for the answers.
The problem is I am launching `rigctld` from a python3 application I am
writing:

print('INFO: Starting `rigctld` for the %s...' % self.name)
model = '--model=' + self.model
rig_file = '--rig-file=' + self.rig_file
port = '--port=' + self.port
shell_command = ['/usr/bin/rigctld', model, rig_file, port]

daemon = subprocess.Popen(shell_command, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, error = daemon.communicate()

When the python application finishes, `rigctld` keeps running.
Thanks to your suggestions, I can manually find the process with `$
pidof rigctld` and `$ sudo kill pid` it.
However, when I relaunch my python program, I can no longer restart
`rigctld`,
as if something kept hanging about.
I need to restart my system to get it running again.

Apparently, I am not alone experiencing such problems.
The authors of CQRLOG have also been struggling with this:
https://github.com/ok2cqr/cqrlog/search?q=rigctld&type=Code&utf8=✓
https://github.com/ok2cqr/cqrlog/issues/35
Unfortunately, CQRLOG is Free Pascal, which is not very helpful to me.

In view of this, I would really welcome an inherent
$ rigctl --model=2 --port=4532 kill
command to kill off `rigctld` daemons.

In the mean time, any python specific launch/kill suggestions are more
than welcome.

Finally, from the mailgroup
https://sourceforge.net/p/hamlib/mailman/hamlib-stationserver/
and
https://sourceforge.net/projects/hamlib/files/stationserver/documents/requirements/
I see, you guys are playing with the idea of a hamlib-stationserver.
Having a service start/stop would be great!
If it gets developed in python3 (which is probably the easiest language
for most of us to pick up), I could actually contribute some code.

Looking forward to your reactions!

73 de Serge, ON4AA
Bill Somerville
2017-01-25 15:59:19 UTC
Permalink
Post by Serge Stroobandt
daemon = subprocess.Popen(shell_command, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, error = daemon.communicate()
When the python application finishes, `rigctld` keeps running.
Hi Serge,

you have several options. You should consider something like:

1) use daemon.send_signal(CTRL_C_EVENT),
2) if that doesn't succeed try daemon.terminate(),
3) if that doesn't work try daemon.kill().

In each case call daemon.communicate() again to wait for termination.

I'm not sure subprocess.POpen.communicate() is the best option for a
long running sub-process, instead use run() and then to shut down use
send_signal() followed by terminate() then kill() each time using poll()
to check if they worked and exit after the first poll() that indicates
the sub-process has exited.

73
Bill
G4WJS.

Loading...