1

I want to run a process that checks my key press state, parallel to my existing infinite loop (from pcap header). I was looking something very similar to GetAsyncKeyState that of Windows.

I tried for a whole week and found its hard to program something similar to GetAsyncKeyState. So, I was using Termination Signal like ctrl+c to perform certain operation.

I wanted to know, if there are some other similar Termination signals that I can catch using program to perform operation of my own?

P.S. I'm a beginner for Linux and C++. Sorry, if my question is stupid.

Newton Falls
  • 2,148
  • 3
  • 17
  • 22
Uday
  • 45
  • 6
  • You are probably looking for [`ncurses`](http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/). – zwol Jul 02 '14 at 02:15

2 Answers2

1

POSIX makes SIGUSR1 and SIGUSR2 available for application use. Additionally there are the set of realtime signals. A close reading of man (7) signal should provide the basics and ample reference material is available on the web.

That said, it sounds like you are headed toward expanding what is already an awkward hack. Perhaps you should ask a separate question detailing exactly what you are doing and someone can help you with a more appropriate path toward solving your primary problem rather than improvements on a work-around.

Duck
  • 26,924
  • 5
  • 64
  • 92
  • Firstly,Thanks for the answer. That's very true, the very starting problem is, I wanted a non-blocking key read instruction (something very similar to GetAsyncKeyState). I did bit of home work, but really did not find anything helpful. If you can throw some light on this, it would be of great help. Thanks again. – Uday Apr 28 '14 at 15:35
  • 1
    I'm not that familiar with windows but the closest you are probably going to get are things like [this](http://stackoverflow.com/questions/448944/c-non-blocking-keyboard-input), [that](http://stackoverflow.com/questions/2984307/c-key-pressed-in-linux-console), or the [other thing](http://stackoverflow.com/questions/717572/how-do-you-do-non-blocking-console-i-o-on-linux-in-c). Not sure these meet your needs but it is what it is. – Duck Apr 28 '14 at 16:11
  • Thanks! It helped me. I have written a function with the help of 'termios.h' – Uday Apr 29 '14 at 15:37
0

you can catch the pid (Process identifier of your program) and with another terminal put kill -9 {pid}

to get the pid just type in terminal ps -u {username}

or you can open application monitor (it's like the task admin of windows)

xgc1986
  • 868
  • 6
  • 8