erondem
Posts: 23
Joined: Wed Jul 11, 2018 12:19 pm

How to shut down a program ?

Mon Oct 01, 2018 11:13 am

Hi,

In my raspberry, there is a program running at startup and when I try to kill with command

Code: Select all

sudo kill -9 PIDNUMBER
the program just restarts itself again. Program has written before but not by me.
I looked for methods to start a program at boot and check them but none of them helped me. (https://www.dexterindustries.com/howto/ ... t-startup/)

So it is a reverse engineering question. If a C program restarts itself after sudo kill command where should I look to disable it?

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: How to shut down a program ?

Mon Oct 01, 2018 11:18 am

depends on the program ,
but if this is started via systemd look at the service file as it may have options set for restart

what is this program ,
where has it come from
why do you want to stop it
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How to shut down a program ?

Mon Oct 01, 2018 11:24 am

Could have been helpful to know the name of the program.

If the program is installed as a "service" then the "systemd" is responsible of restarting the service if it stops for any reason.

To list all the services registered use the command "systemctl".
To correctly stop a service use "systemctl stop name".
To disable it completely use "systemctl disable name".

erondem
Posts: 23
Joined: Wed Jul 11, 2018 12:19 pm

Re: How to shut down a program ?

Mon Oct 01, 2018 11:28 am

RaTTuS wrote:
Mon Oct 01, 2018 11:18 am
depends on the program ,
but if this is started via systemd look at the service file as it may have options set for restart

what is this program ,
where has it come from
why do you want to stop it
It is a C program which sends sensor data to a server. I made some changes, since I couldnt shut the first version I can not test properly.
It is under /usr/ folder.

What should I search in the systemd folder?

Edit:
topguy wrote:
Mon Oct 01, 2018 11:24 am
Could have been helpful to know the name of the program.

If the program is installed as a "service" then the "systemd" is responsible of restarting the service if it stops for any reason.

To list all the services registered use the command "systemctl".
To correctly stop a service use "systemctl stop name".
To disable it completely use "systemctl disable name".
Thanks for helpful comment. I couldn't find the name of my program in the list when I enter systemctl

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How to shut down a program ?

Mon Oct 01, 2018 11:37 am

Code: Select all

rgrep "name" /etc/systemd
This would be a quick way to see if there are any installed services for the program.

erondem
Posts: 23
Joined: Wed Jul 11, 2018 12:19 pm

Re: How to shut down a program ?

Mon Oct 01, 2018 11:46 am

topguy wrote:
Mon Oct 01, 2018 11:37 am

Code: Select all

rgrep "name" /etc/systemd
This would be a quick way to see if there are any installed services for the program.
Can this somehow be related with "avahi"? When I entered ps -eaf I see there :

avahi-daemon: running [NAMEOFMYPROGRAM.local]

DirkS
Posts: 10371
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: How to shut down a program ?

Mon Oct 01, 2018 12:01 pm

erondem wrote:
Mon Oct 01, 2018 11:46 am
avahi-daemon: running [NAMEOFMYPROGRAM.local]
Don't think so. That's most likely

Code: Select all

avahi-daemon: running [NAMEOFYOURASPBERRYPI.local]

DirkS
Posts: 10371
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: How to shut down a program ?

Mon Oct 01, 2018 12:06 pm

topguy wrote:
Mon Oct 01, 2018 11:37 am

Code: Select all

rgrep "name" /etc/systemd
This would be a quick way to see if there are any installed services for the program.
You would also have to check /lib/systemd

And you can also use <TAB> completion; it works with all the systemctl commands.
'systemctl status ' + <TAB> will show all 350+ or so services.

Return to “Beginners”