c in linux
I am using c language under linux. I want to run more than one processes simultaneously in background in a single terminal. What i am needed really is how to get a single character input from the keyboard to that processes running in the background.
|
are you asking about threading in c? or just running multiple processes from one console
|
Background processes are created by including an & after invoking the program. If a program is named a.out you would start it with ./a.out & . There is a space after the invocation of the program. You can end the backgrounding with an fg (foreground) command. If there are multiple backgrouded programs you will be able to choose between them.
|
Quote:
#1. How do the programs go into background? #2. When, where and why do they need to get a character from the user? |
Threading and multiple processes are not the same thing either.
If we talk threading, the main thread and the background thread can share come kind of global variable, using mutexes to stay out of each other's way. A better solution if to use queues (I suppose that NPTL has those, I'm used to Python). As for multiple processes, you'd use mmap, pipes or the like. |
Quote:
|
Quote:
I just made the programs to run in the background by "./a.out &". But i need the backgound process to get the input from the keyboard(NOT CTRL+Z,etc....) Also tell me how to get the input in non-canonical mode |
Background process does not take any keyboard input. At least directly. You need to bring it back into foreground and then may handle the input data again. Alternatively, the process (still in background) can use any interprocess communication method (like pipe or local socket) to get the data from another process.
|
what is the goal here, a keylogger?
|
All times are GMT -5. The time now is 05:53 AM. |