windows和linux的進程建立 CreateProcess 和 fork

來源:互聯網
上載者:User

windows下有沒有 類似 fork 的函數呢?fork可以從當前 複製所有進程資訊都另一個進程,然後兩個進程可以執行不同的代碼。

windows顯然沒有fork。只有CreateProcess,但是CreateProcess有很多參數:

BOOL WINAPI CreateProcess(  _In_opt_     LPCTSTR lpApplicationName,  _Inout_opt_  LPTSTR lpCommandLine,  _In_opt_     LPSECURITY_ATTRIBUTES lpProcessAttributes,  _In_opt_     LPSECURITY_ATTRIBUTES lpThreadAttributes,  _In_         BOOL bInheritHandles,  _In_         DWORD dwCreationFlags,  _In_opt_     LPVOID lpEnvironment,  _In_opt_     LPCTSTR lpCurrentDirectory,  _In_         LPSTARTUPINFO lpStartupInfo,  _Out_        LPPROCESS_INFORMATION lpProcessInformation);

http://msdn.microsoft.com/en-us/library/ms682425(v=vs.85).aspx

看來用法是 指定一個 exe的路徑,然後指定參數,來運行這個exe。 linux下也是有Exec類似的函數的,類似CreateProcess的。

如果 建立進程 跟 建立線程一樣,指定一個函數地址,和參數,那該多好啊。。。。。。

 

相關資料:[回溯本源] Unix Fork和Windows CreateProcess可以比較嗎?

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.