can't understand why service doesn't stop...

79 views
Skip to first unread message

Gabriele Desinano

unread,
Feb 7, 2021, 7:28:05 PM2/7/21
to Alt-F

Hi all,

I can't understand the way to let stop a service started as "user service".

this is the userboot.sh file that I'm using: it's almost the original one with less modifications:


#!/bin/sh

# Script to execute as the root user at boot time.
# You can loose your data or make the system inaccessible
# if using the wrong commands. You have been warned!
 
exec >> /var/log/user.log 2>&1

case "$1" in
    start)
        echo "Starting $0"
/mnt/sistema_usb/mlnet_start.sh
        ;;
    stop)
        echo "Stopping $0"
killall mlnet
killall mlnet-arm
killall mlnet-nogui
killall mlnet-nogui-arm
        ;;
esac

The mlnet_start.sh  long and confused because it needs to set some variabiles and rules to delete directories, create symlinks and apply permissions, so I just report the simplest possible to see:


###################################################
#   EXECUTABLE MLDONKEY START
###################################################
#
#
/mnt/sistema_usb/SERVIZI/mldonkey-arm/bin/mlnet
#


It starts, it works, but I can't stop it from the user services page.


PLEASE ANY SUGGESTION?

Gabriele Desinano

unread,
Feb 21, 2021, 10:45:58 AM2/21/21
to Alt-F
I answer to myself:  I just needed to add the "-9" option to the command.... so THOSE ARE THE COMMANDS THAT WORK TO STOP THE USER SERVICES:
killall -9 mlnet
killall -9 mlnet-arm
killall -9 mlnet-nogui
killall -9 mlnet-nogui-arm
killaall -9 "servicename"

:( :( :(

João Cardoso

unread,
Feb 21, 2021, 3:01:01 PM2/21/21
to Alt-F
On Sunday, February 21, 2021 at 3:45:58 PM UTC Gabriele Desinano wrote:
I answer to myself:  I just needed to add the "-9" option to the command.... so THOSE ARE THE COMMANDS THAT WORK TO STOP THE USER SERVICES:
killall -9 mlnet
killall -9 mlnet-arm
killall -9 mlnet-nogui
killall -9 mlnet-nogui-arm
killaall -9 "servicename"

Not really.
Different process need different ways to terminate. Programs can intercept and handle signals sent to them, and they can choose to ignore them, or expect a given signal to be sent to one of them, that process will then use whatever ways it has setup to terminate other cooperating processes. The only way to know is to read its manual (man) pages and look how they handle signals and how are they are supposed to terminate. E.g. "man mlnet" directed me to https://helpmanual.io/man1/mlnet. Yes, long reading, and not complete.

While most processes handle a 'kill' by terminating, others ignore it and require a kill -1, or a kill -2, or whatever. A kill -9 is "sure" kill, except if the processes has requested a kernel service that is blocked by some reason (mostly disk realted); in that case, you can't terminate the process, you see the process marked with a "D" state under top or ps.

Terminating a process using a kill -9 is dangerous. Imagine that the process is updating a database, and is killed during that transaction -- data will become corrupted. Imagine your bank account being updated, for a motivating enough example.

 No, I don't know how mlnet works, neither how to tell it to terminate. It might be as simple as telling it to run in the background... on forks or old and not maintained programs, there are deviations on that. The above manual, e.g. says:

This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page.
(...) 

-daemon

this argument was removed, core will exit

Gabriele Desinano

unread,
Feb 25, 2021, 7:04:12 PM2/25/21
to Alt-F

 Really thanks, you understand it: I'm not an expert and your lesson sounds like a little milestone for me.  I always need searching for help for everything. Fortunatelly a lot of skilled people like you help who needs help.

I believed to help others telling about the way to kill this service, good thing that you explaned more about it.

Thanks
Reply all
Reply to author
Forward
0 new messages