[RESOLVED] run background process without &
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: [RESOLVED] run background process without &

  1. #1
    Join Date
    Apr 2011
    Posts
    29

    [RESOLVED] run background process without &

    hi,
    I ve written a Makefile for my c++ files. in that i create targets for server and client. i ve to run the server in the background.but wen i execute the target i should not be using & ie, "./server& " should not be used.. instead i should execute as " ./server " but it has to run at the background....Can any one tell me how i should do this pls....

  2. #2
    Join Date
    Nov 2003
    Posts
    1,825

  3. #3
    Join Date
    Apr 2011
    Posts
    29

    Re: run background process without &

    hi,,
    thankx for response.. but the link u sent me is a normal file... can u help me out with some make files so that i can modify my file....

  4. #4
    Join Date
    Nov 2003
    Posts
    1,825

    Re: run background process without &

    If your application does not run in the background automatically (fork/setsid), then you have to tell the shell to run the app in the background for you. Make uses "sh" as the default shell. It uses "&" to run things in the background.

    >> "./server& " should not be used.
    Why? That's how you tell the shell to run it in the background...

    gg

  5. #5
    Join Date
    Apr 2011
    Posts
    29

    Re: run background process without &

    thankx for the reply....i m new to this sh commands...so can u pls tell me exactly how shud i run my executable...
    sh ./server is it.... and what is the modification i have to do to my makefile or is there anythin i got to include with it....
    and der is one more this my executable is a binary executable..so wil there be problem using sh...

    Can u pls tell me exactly how to use sh for binary executable...
    Last edited by sandy2511; April 19th, 2011 at 12:47 AM. Reason: did not tell it wa a binary executable..

  6. #6
    Join Date
    Apr 2011
    Posts
    29

    Re: run background process without &

    hi,

    The binary 'server' should be a daemon binary.
    (ie)
    The binary should run as back-ground process by default.
    (i.e, without specifying '&' symbol)....

    This is what my question was exactly....

  7. #7
    Join Date
    Nov 2003
    Posts
    1,825

    Re: run background process without &

    >> The binary 'server' should be a daemon binary.
    How to do that was given in post #2.
    Call fork(), exit() and setsid().

    gg

  8. #8
    Join Date
    Apr 2011
    Posts
    29

    Re: run background process without &

    ya got it thankx...

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center