79443629

Date: 2025-02-16 17:35:00
Score: 0.5
Natty:
Report link

The solution was to close the pipe handles after creating the process.

So

  if (!CreateProcess( 
    NULL,
    filename, //TODO: check unicode?
    NULL,
    NULL,
    TRUE,
    0,
    NULL,
    NULL,
    &si,
    pi)
  ) {
    printf("Could not create process\n");
    return NULL;
  }
CloseHandle(g_hChildStd_OUT_Wr); 
CloseHandle(g_hChildStd_IN_Rd);

I guess because then only the child holds a handle to the resources, not the parent.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Hellstorm