Answer the question
In order to leave comments, you need to log in
How to run a bash script on button press and terminate on release?
There is a task:
- We pressed and hold the button connected via the Raspberry pi 3+ GPIO comb - The
script started
- The button was released
- The script was forced to stop
Googling did not help, I found only the launch of the script
How can this be implemented? Generally. not necessarily bash, you can python. php
Answer the question
In order to leave comments, you need to log in
on click, run the script in the background, in the script write its PID
to the file, kill it on releasekill $(cat myscript.pid)
You can stop and continue the execution of a process in Linux using the kill function .
Here is an example in Python.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question