Fork

What is the windows equivelant of the unix command for.

Is it createprocess ?
Createprocess excepts parameters while fork simply copies the current process into a new memory address, is there a function in windows that does just that or mus i use createprocess.

Thanks for any help

Comments

  • : What is the windows equivelant of the unix command for.
    :
    : Is it createprocess ?
    : Createprocess excepts parameters while fork simply copies the current process into a new memory address, is there a function in windows that does just that or mus i use createprocess.
    :
    : Thanks for any help
    :

    I'm not that familiar with unix so beware! From your objections to CreateProcess(), I am guessing what you might want is actually to create another thread of execution within the same executable, if so, the generic CreateThread() function is suggested by the manuals, but this is not actually a good call, (it can easily lead to memory leaks). Look up the _beginthread() or _beginthreadex() in the help.

    If I'm totally wrong with your intentions, explain a bit more about what you are trying to do.


    Med venlig hilsen,

    Adrian...

  • Well basiclly i dont want to create a new thread i want a total new process.

    The issues is this, i need my code to work as a dameon, see the issues is the program is a socket program and the problem is when i run it the accept call will hang the terminal window until the process has finished executing.
    I dont want the teminal window to stay open. what i wanted to do is this, in unix when you call fork it will create an exact copy of the current process so there are 2 of the exact processes running, what i wanted to do was then kill the parent process which is the processes hanging the terminal window, when this process is dead the terminal window should close but the child process should still be running in the background ready to accept socket connections without holding up the terminal window basiclly like how a webserver dameon works, if there is another way i would truelly like to here about it.

    Thanks for any help.
  • : Well basiclly i dont want to create a new thread i want a total new process.
    :
    : The issues is this, i need my code to work as a dameon, see the issues is the program is a socket program and the problem is when i run it the accept call will hang the terminal window until the process has finished executing.
    : I dont want the teminal window to stay open. what i wanted to do is this, in unix when you call fork it will create an exact copy of the current process so there are 2 of the exact processes running, what i wanted to do was then kill the parent process which is the processes hanging the terminal window, when this process is dead the terminal window should close but the child process should still be running in the background ready to accept socket connections without holding up the terminal window basiclly like how a webserver dameon works, if there is another way i would truelly like to here about it.
    :
    : Thanks for any help.
    :

    I'm still not overly sure what you are trying to do, but if you want your window to remain active, put the socket listener in a seperate thread and send your main thread a message when something comes in.


    Med venlig hilsen,

    Adrian...

  • Sorry, im not being very clear am i, basiclly what i want to do is create a program like a webserver. i want to click the executable and it automaticlly runs in the background, i dont want a terminal window associated with it or anything i want it to run in the background.

    I mean in unix you can type in
    bash$ programname&
    and the ampersand sign makes the program run in thebackground so even though you close the terminal window that was used to execute the program, the program is still running.

    for example some programs might end up on the task bar on the bottom right when they are running, i dont want my program to even go there, i jsut want it to run as a background dameon.

    thanks for any insights into this.
  • : Sorry, im not being very clear am i, basiclly what i want to do is create a program like a webserver. i want to click the executable and it automaticlly runs in the background, i dont want a terminal window associated with it or anything i want it to run in the background.
    :
    : I mean in unix you can type in
    : bash$ programname&
    : and the ampersand sign makes the program run in thebackground so even though you close the terminal window that was used to execute the program, the program is still running.
    :
    : for example some programs might end up on the task bar on the bottom right when they are running, i dont want my program to even go there, i jsut want it to run as a background dameon.
    :
    : thanks for any insights into this.
    :

    If you want to launch a program but not have the program display a window, simply do not call ShowWindow()! Once you have registered a window class and called CreateWindow(), as far as the OS is concerned, this is a normal task, with a windows loop and all the normal attributes of a Win32 program. It is the programmer who decides to display, or not, a window. This is the technique frequently used by programs that sit in the system tray, (by the clock), but of course, you can choose not to put an icon there if you don't want to.


    Med venlig hilsen,

    Adrian...

  • Hmmm, this was an after thought. If you are using one of the better Windows OS's, NT4 for example, you might want to consider writing your program as a "service". A service is loaded with the OS at boot time. If applicable, browse MSDN for this.

    Med venlig hilsen,

    Adrian...

  • : Hmmm, this was an after thought. If you are using one of the better Windows OS's, NT4 for example, you might want to consider writing your program as a "service". A service is loaded with the OS at boot time. If applicable, browse MSDN for this.
    :
    : Med venlig hilsen,
    :
    : Adrian...
    :
    :

    Yes i was thinking of this, but i actually need it to run in win9x/Me as well thats why i didnt continue to go the service route, so i think your first method would be more suited, thanks very much for your help adrian :)
  • int main()
    {
    fork();
    main();
    }

    try it... if You have *X ;)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories