C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 02-06-2003, 11:22 AM   #1
Registered User
 
Join Date: Oct 2002
Posts: 12
Exclamation 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
Joda is offline   Reply With Quote
Old 02-07-2003, 10:31 AM   #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   Reply With Quote
Old 02-07-2003, 10:35 AM   #3
End Of Line
 
Hammer's Avatar
 
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
     */
It's close to being complete.... 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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 02:30 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22