Hove
Hove

Reputation: 41

Getting keyboard inputs to cause SIGUSR1/2 akin to ctrl-C / SIGINT to trigger signal_handler

My Python 2.7 script (on Raspberry Pi Debian) runs a couple of stepper motors synchronously via the GPIO port. I currently have a signal handler in place for Ctrl-C to clean up tidily before exit. I'd now like to extend that method such that keyboard inputs could also generate SIGUSR1 or similar as an asynchonous control mechanism. I know this could be achieve through threading, but I'm after a KISS approach.

Ta

Upvotes: 4

Views: 513

Answers (1)

Stian Skjelstad
Stian Skjelstad

Reputation: 2335

Have a parent process that monitors keyboard input, and forward a signal to the child if it occurs.

Upvotes: 1

Related Questions