![]() |
| | #1 |
| Registered User Join Date: Oct 2002
Posts: 12
| 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 |
| Joda is offline | |
| | #2 |
| Registered User Join Date: Oct 2002
Posts: 12
| hey! is there any "hello world" like examples on how to do this? thanks for the feedback! - suddenad |
| Joda is offline | |
| | #3 |
| End Of Line Join Date: Apr 2002
Posts: 6,240
| 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
*/
I just hacked this out of an app, you can amend it to suit your needs
__________________ When all else fails, read the instructions. If you're posting code, use code tags: [code] /* insert code here */ [/code] |
| Hammer is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wireless Network Linux & C Testbed | james457 | Networking/Device Communication | 3 | 06-11-2009 11:03 AM |
| processes, threads, gtk development, portability on linux and win32 | odysseus.lost | C Programming | 1 | 10-24-2005 06:35 AM |
| if you dont like linux threads, dont read... | ... | A Brief History of Cprogramming.com | 4 | 02-03-2003 11:26 AM |
| threads and linux | shaka87 | C Programming | 1 | 06-07-2002 03:59 AM |