View Full Version : Doing two things at once

08-03-2004, 10:22 PM
I want to make a console program able to output text and do other things while a user is typing input. I'm going to use ncurses for the display. How could I do two things at the same time?

08-03-2004, 10:27 PM
off the top of my head
You can use select() on stdin to see if there is any data to be processed

08-03-2004, 10:51 PM
hi eam,

you should take a look in fork() and clone() linux syscalls. they work similar to w32 threads.


08-03-2004, 10:52 PM
How would I do that?

08-03-2004, 11:07 PM

already tried http://www.google.com/search?q=linux+fork+syscall ? :rolleyes:

or the linux secret command "man"? ;)


08-03-2004, 11:09 PM
Actually fork() and clone() are NOT like windows threads. fork() creates another process with its own memory space. If you want multi threaded applications you need to look into pthreads

08-03-2004, 11:51 PM
Guess I have some reading to do then, thanks for pointing me in the right direction.

08-04-2004, 10:10 PM
Not to try and say that you are wrong Thantos, just to shed a little more light on the subject. Threads in linux are implemented as their own processes. They just so happen to have the same pid and their address space pointer points to the address space of the other process it is a thread of :). They are called lightweight processes.