4 #include <msvcrt/errno.h>
5 #include <msvcrt/stdio.h>
6 #include <msvcrt/stdlib.h>
7 #include <msvcrt/string.h>
8 #include <msvcrt/internal/file.h>
11 FILE *_popen (const char *cm
, const char *md
) /* program name, pipe mode */
14 HANDLE hReadPipe
, hWritePipe
;
15 STARTUPINFO StartupInfo
;
16 PROCESS_INFORMATION ProcessInformation
;
20 // if ( !CreatePipe(&hReadPipe,&hWritePipe,NULL,1024))
23 StartupInfo
.cb
= sizeof(STARTUPINFO
);
25 StartupInfo
.hStdOutput
= hWritePipe
;
27 else if ( md
== "w" ) {
28 StartupInfo
.hStdInput
= hReadPipe
;
31 if (CreateProcessA("cmd.exe",(char *)cm
,NULL
,NULL
,TRUE
,
32 CREATE_NEW_CONSOLE
,NULL
,NULL
,
34 &ProcessInformation
) == FALSE
)
39 pf
= _fdopen( __fileno_alloc(hReadPipe
, _fmode
) , "r" );
42 pf
= _fdopen( __fileno_alloc(hWritePipe
, _fmode
) , "w" );
45 pf
->_name_to_remove
= ProcessInformation
.hProcess
;
58 printf("Terminate Process\n");
59 // if (!TerminateProcess(pp->_name_to_remove,0))