Possible Duplicate:
How to fetch data in a background process in Ubuntu
I am writting a program which monitors the keys pressed on a keyboard. But my program may be running in foreground or in background. I heard that there is OS specific system call which lets the programmer to monitor keyboard activity even when the program running the system call is in background. I am new to Ubuntu programming so please somebody tell me what is that OS system call.
Note: This program is strictly for educational purposes. It is a part of School project..
Regards
-
7Yes, I'd be delighted to help you develop spyware. Seriously, if you post an ethical reason why you want to do OS level keylogging on a Linux machine, perhaps people will help.Jeff Watkins– Jeff Watkins2012年10月05日 13:05:38 +00:00Commented Oct 5, 2012 at 13:05
-
This program is for educational purposes because I am learning unix/ubuntu programminguser1698102– user16981022012年10月05日 13:08:52 +00:00Commented Oct 5, 2012 at 13:08
-
4As a beginner, you might want to start with something that is both simple and unsuspicious.Erich Kitzmueller– Erich Kitzmueller2012年10月05日 13:11:07 +00:00Commented Oct 5, 2012 at 13:11
-
2Same user, same question: stackoverflow.com/questions/12744064/…Derek– Derek2012年10月05日 13:37:13 +00:00Commented Oct 5, 2012 at 13:37
-
@user1698102: you should hear less (hearing about an OS specific system call to monitor keyboard is bullshit) and read, study, experiment and code much more.Basile Starynkevitch– Basile Starynkevitch2012年10月05日 14:33:34 +00:00Commented Oct 5, 2012 at 14:33
3 Answers 3
Most Ubuntu systems (at least desktop for novice Ubuntu users) are running an X11 window server (like Xorg). That server (only) is getting the raw keyboard and mouse device inputs. It processes them to deliver X11 protocol events to client applications (like e.g. your firefox browser, or your emacs editor, or your gnome or xterm terminal).
You could spend your time (months) understanding all of them (perhaps starting from freedesktop) You could also switch to some other project, perhaps just coding an interesting GUI application using Gtk (within Gnome) or Qt (within KDE). All Linux graphical toolkits libraries are built above a library interfacing the X11 protocol, usually Xlib, or XCB.
If you want to start learning Linux programming, read Advanced Unix Programming and Advanced Linux Programming. After than, take a lot of time to understand the mysteries of tty-s, and become familiar with syscalls(2). Then become familiar with a graphical toolkit like Qt or GTK.
And then you'll just begin to understand how hard it is to answer precisely your ill-asked and suspicious question. (the answer strongly depends upon the point of view - Xorg seeing different key events than other applications, notably X clients, and is very complex).
Once you've understood all the concepts in the links I gave you, you'll be able to ask more precisely your question. When you'll re-ask your question in more precise and technical terms (in particular explaining at which level you want to monitor the keyboard & mouse), showing the code that you experimented, we'll be able (and willing) to answer you.
1 Comment
heard that there is OS specific system call: who did you hear that from? Did you ask them?
This requires more than one call, you need to use ioctl (might be different on Ubuntu) to push your logger into the terminal stream. It is not simple, and not really suitable for a beginning project. For an example, see the script program.
2 Comments
There is a program for linux, which binds global hotkeys and perform predefined actions on key press. It is called xbindkeys. Look in its source code for suggestion or simply use it as it is.