-
Threads in Linux!
hey!
Im working on a imgviewer on linux, when I launch
it from xterm it is using xterms's thread to
recieve I/O. This is a problem, I want to
use a separate thread and have it act as if
I called the app using the & sign, like
"./imgview &".
How do I do this? I know some stuff about
multithreaded apps but I dont think this is
exactly what I want.
All feedback is welcome!
- Suddenad
-
hey!
is there any "hello world" like examples on how
to do this?
thanks for the feedback!
- suddenad
-
Code:
int main(int argc, char *argv[])
{
pid_t pid;
switch (pid = fork())
{
case -1:
perror("fork");
return (EXIT_FAILURE);
break;
case 0:
sleep(1);
if( setsid() == -1 )
{
perror("setsid");
}
break;
default:
_exit(EXIT_SUCCESS);
break;
}
/*
* We have now forked and setup our own group, detached from the terminal
*/
It's close to being complete.... ;) I just hacked this out of an app, you can amend it to suit your needs