I have a custom program that I am running under OpenSuse 11.1, gnome environment.
As part of the program, I have a quit function that cleanly exits the program whenever the ‘q’ key is hit. This program uses the opencv function “cvWaitKey()” to obtain a keyboard hit. The program’s window must be selected for this command to work.
My question is: is there a way for me to send a quit command through the terminal/command line to my program?
Ideally what I want to do is to set up a shell script that will run every minute to check for an alert (via the crontab). And if the alert is set then this script will send the quit command to the program.
I appreciate any advice to help with this. Thank you!
I think if you look through the forum you’ll find a similar question a while back. There’s a command X utility to send an arbitrary X event to a specified window. An X event can be a keystroke, a mouse event, and various other windowing system events. Sorry, don’t have the link, just something at the back of my mind.
Thanks for the input guys, I’ll try making a function that will respond to the SIGTERM signal and see how it works out. (I believe this is signal handling from what I’ve read up so far - InformIT: C++ Reference Guide > Signal Processing . Do you know any other tutorial pages that would be helpful for doing this?)