Find the answer to your Linux question:
Results 1 to 6 of 6
hi all can fork is used as a thread? tnak you in advance...
  1. #1
    Linux Newbie
    Join Date
    Feb 2007
    Location
    hyderabad, india
    Posts
    247

    fork()

    hi all
    can fork is used as a thread?

    tnak you in advance

  2. #2
    Just Joined!
    Join Date
    Jan 2007
    Posts
    90
    yes.
    But fork creates processes. So the entire process will be duplicated and not just another instance of the thread !

  3. #3
    Just Joined!
    Join Date
    Feb 2007
    Posts
    12
    how do i make a process sleep for n seconds?

    i'm having a problem, when i create a process like

    Code:
     
    child2 = fork();
    printf("%d", child2);
    child2 gets printed twice. once as a 0 and once as its real process id. how can i make it print only once?

  4. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Smile

    Hi,
    Printf() is called once by ur parent process then by child process.so u get tw o ouptuts.
    child process pid is always zero and parent process greater than zero.
    use sleep() or wait() to delay process.

    i found this link simple and easy

    http://www.secgeeks.com/?q=node/201
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  5. #5
    Linux Newbie
    Join Date
    Feb 2007
    Location
    hyderabad, india
    Posts
    247
    yeah..
    i used pthreads concept

    pthread_t thread1;
    int iret1;
    iret1=pthread_create( &thread1, NULL, myfunction, NULL);
    //pthread_join( thread1, 0);

    here my function having gtk application(gui)
    in this it calls the browser, when the browser calls using threads my gui application getting
    hanged, for that i used
    pthread_join( thread1, 0);

    still it is hanging..

    i used this thread in othen function(not in main()).

    can any help?

    thank you in advance

  6. #6
    Just Joined!
    Join Date
    Feb 2007
    Posts
    12
    thx Laksh, that was helpful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...