Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Create Process + WaitForSingleObject hangs

Create Process + WaitForSingleObject hangs

Scheduled Pinned Locked Moved C / C++ / MFC
oophelpquestionworkspace
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 404410
    wrote on last edited by
    #1

    Hi, I have a problem with WaitForSingleObject. my code are as follows int RunExternalProES(LPTSTR ExecProc, int option) { STARTUPINFO si; PROCESS_INFORMATION pi; DWORD pProcessID; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess(NULL, // No module name (use command line). ExecProc, // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. TRUE, // Set handle inheritance to FALSE. 0, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. ) { return FALSE; //( "CreateProcess failed." ); } if (option == 1) { WaitForSingleObject(pi.hProcess, INFINITE); } } i found that sometime waitforsingleobject function will hang for some process.. is there any reson why this happens? Thanks

    V 1 Reply Last reply
    0
    • U User 404410

      Hi, I have a problem with WaitForSingleObject. my code are as follows int RunExternalProES(LPTSTR ExecProc, int option) { STARTUPINFO si; PROCESS_INFORMATION pi; DWORD pProcessID; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess(NULL, // No module name (use command line). ExecProc, // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. TRUE, // Set handle inheritance to FALSE. 0, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. ) { return FALSE; //( "CreateProcess failed." ); } if (option == 1) { WaitForSingleObject(pi.hProcess, INFINITE); } } i found that sometime waitforsingleobject function will hang for some process.. is there any reson why this happens? Thanks

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      The process that spawns the new process has limited knowledge of what goes on afterward. If WaitForSingleObject() does not return for a long time then I suspect that the spawned process is not exiting. Kuphryn

      R 1 Reply Last reply
      0
      • V valikac

        The process that spawns the new process has limited knowledge of what goes on afterward. If WaitForSingleObject() does not return for a long time then I suspect that the spawned process is not exiting. Kuphryn

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        kuphryn wrote: I suspect that the spawned process is not exiting. Yes, that would be my assumption as well

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups