50 likes | 393 Views
UNIX Fork/Exec Example. int pid = fork(); if ( pid == 0) { exec("foo"); } else { waitpid ( pid , &status, options); };. Child process. Parent process. Windows Process Creation. BOOL CreateProcess ( LPCTSTR lpApplicationName , LPTSTR lpCommandLine ,
E N D
UNIX Fork/Exec Example intpid = fork(); if (pid == 0) { exec("foo"); } else { waitpid(pid, &status, options); }; Child process Parent process CS 140 Lecture Notes: Threads, Processes, and Dispatching
Windows Process Creation BOOL CreateProcess( LPCTSTR lpApplicationName, LPTSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCTSTR lpCurrentDirectory, LPSTARTUPINFO lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation ); WaitForSingleObject(lpProcessInformation->hProcess, INFINITE); CS 140 Lecture Notes: Threads, Processes, and Dispatching