The R Project SVN R

Rev

Rev 52836 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 52836 Rev 52837
Line 345... Line 345...
345
  redirect stdin for the child.
345
  redirect stdin for the child.
346
*/
346
*/
347
int runcmd(const char *cmd, cetype_t enc, int wait, int visible,
347
int runcmd(const char *cmd, cetype_t enc, int wait, int visible,
348
	   const char *fin, const char *fout, const char *ferr)
348
	   const char *fin, const char *fout, const char *ferr)
349
{
349
{
350
    HANDLE hIN = getInputHandle(fin), hOUT = getOutputHandle(fout),
350
    HANDLE hIN = getInputHandle(fin), hOUT, hERR;
351
	hERR = getOutputHandle(ferr);
-
 
352
    int ret = 0;
351
    int ret = 0;
353
    PROCESS_INFORMATION pi;
352
    PROCESS_INFORMATION pi;
354
 
353
 
-
 
354
    hOUT = getOutputHandle(fout);
-
 
355
    if (streql(fout, ferr)) hERR = hOUT;
-
 
356
    else hERR = getOutputHandle(ferr);
355
    if (!hOUT || !hERR) return 1;
357
    if (!hOUT || !hERR) return 1;
356
 
358
 
357
    memset(&pi, 0, sizeof(pi));
359
    memset(&pi, 0, sizeof(pi));
358
    pcreate(cmd, enc, !wait, visible, hIN, hOUT, hERR, &pi);
360
    pcreate(cmd, enc, !wait, visible, hIN, hOUT, hERR, &pi);
359
    if (!pi.hProcess) return NOLAUNCH;
361
    if (!pi.hProcess) return NOLAUNCH;
Line 415... Line 417...
415
		r->read, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE,
417
		r->read, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE,
416
		&(r->pi));
418
		&(r->pi));
417
	r->active = 1;
419
	r->active = 1;
418
	if (!r->pi.hProcess) return NULL; else return r;
420
	if (!r->pi.hProcess) return NULL; else return r;
419
    }
421
    }
-
 
422
 
420
    /* pipe for R to read from */
423
    /* pipe for R to read from */
421
    hTHIS = GetCurrentProcess();
424
    hTHIS = GetCurrentProcess();
422
    r->write = hWritePipe;
425
    r->write = hWritePipe;
423
    DuplicateHandle(hTHIS, hReadPipe, hTHIS, &r->read,
426
    DuplicateHandle(hTHIS, hReadPipe, hTHIS, &r->read,
424
		    0, FALSE, DUPLICATE_SAME_ACCESS);
427
		    0, FALSE, DUPLICATE_SAME_ACCESS);