Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fork()

Status
Not open for further replies.

dmxd99

Programmer
Jul 19, 2005
20
US
Fork() may be used to create a child process in unix but I am compiling my c codes in visual studio 6.0 and the equivalent API is createProcess() However I have to stick with ANSI C therefore I can't use createProcess() so is there another API that create a child process that can run in Visual studio without using data type such as HANDLE, DWORD, LPVOID etc...
Thanks
 
ANSI Standards don't fork. fork is a POSIX standard and will be found on all *nix boxes (Linux,Unix,BSD,etc.)... createProcess is the closest thing you can get to fork, because that's how they handle the system call.

You could use conditional marcos/preprocessor directives to define how your doing things so that it can be compiled under both.

[plug=shameless]
[/plug]
 
Can you give me a sample code or further explain how conditional macros/preprocessor directives can be used...
 
The only ANSI way to create a new process is with the [tt]system[/tt] function. It usually passes its argument to the OS's main "shell" as a command to parse (maybe?) and execute.

The commands you must pass to it, however, won't work reliably on all OSs (e.g. Unix [tt]ls[/tt] vs. DOS [tt]dir[/tt]), so it's not portable at all. It can also be very insecure.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top