Changeset 8483 for trunk/tools/CmdQd/CmdQd.c
- Timestamp:
- May 24, 2002, 5:39:08 AM (23 years ago)
- File:
-
- 1 edited
-
trunk/tools/CmdQd/CmdQd.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/CmdQd/CmdQd.c
r8482 r8483 1 /* $Id: CmdQd.c,v 1.1 7 2002-05-24 02:41:30bird Exp $1 /* $Id: CmdQd.c,v 1.18 2002-05-24 03:39:08 bird Exp $ 2 2 * 3 3 * Command Queue Daemon / Client. … … 1459 1459 if (pJob) 1460 1460 { 1461 static BOOL fStdClosed = FALSE;1462 static HFILE hStdOutSaved = -1;1461 static HFILE hDummy; 1462 static BOOL fStdClosed = FALSE; 1463 1463 int rc; 1464 int rcDbg; 1464 1465 char szArg[4096]; 1465 1466 char szObj[256]; … … 1492 1493 if (!fStdClosed) 1493 1494 { /* only do this once! */ 1494 DosDupHandle(HF_STDOUT, &hStdOutSaved); 1495 DosSetFHState(hStdOutSaved, OPEN_FLAGS_NOINHERIT); /* child shall not see this handle! */ 1495 HFILE hf; 1496 1496 fclose(stdin); 1497 1497 DosClose(HF_STDIN); 1498 fclose(stdout); 1499 DosClose(HF_STDOUT); 1500 fclose(stderr); 1501 DosClose(HF_STDERR); 1502 hStdOut = HF_STDOUT; 1503 DosDupHandle(hStdOutSaved, &hStdOut); 1504 hStdErr = HF_STDERR; 1505 DosDupHandle(hStdOutSaved, &hStdErr); 1498 hDummy = HF_STDIN; 1499 for (hf = 1; hf < 20; hf++) 1500 if (!(rcDbg = DosDupHandle(hf, &hDummy))) 1501 break; 1502 assert(!rcDbg); 1503 rcDbg = DosSetFHState(hDummy, OPEN_FLAGS_NOINHERIT); assert(!rcDbg); 1504 fclose(stdout); DosClose(HF_STDOUT); 1505 fclose(stderr); DosClose(HF_STDERR); 1506 hStdOut = HF_STDOUT; rcDbg = DosDupHandle(hDummy, &hStdOut);assert(!rcDbg); 1507 assert(hStdOut == HF_STDOUT); 1508 hStdErr = HF_STDERR; rcDbg = DosDupHandle(hDummy, &hStdErr);assert(!rcDbg); 1509 assert(hStdErr == HF_STDERR); 1506 1510 fStdClosed = TRUE; 1507 1511 } … … 1514 1518 return; 1515 1519 } 1516 assert(hPipeW != HF_STDOUT && hPipeR != HF_STDERR); 1520 assert(hPipeW != HF_STDOUT && hPipeW != HF_STDERR); 1521 assert(hPipeR != HF_STDOUT && hPipeR != HF_STDERR); 1517 1522 1518 1523 rc = DosSetDefaultDisk( pJob->JobInfo.szCurrentDir[0] >= 'a' … … 1526 1531 assert( pJob->JobInfo.szzEnv[pJob->JobInfo.cchEnv-1] == '\0' 1527 1532 && pJob->JobInfo.szzEnv[pJob->JobInfo.cchEnv-2] == '\0'); 1528 DosDupHandle(hPipeW, &hStdOut);1529 DosDupHandle(hPipeW, &hStdErr);1530 DosClose(hPipeW);1531 DosSetFHState(hPipeR, OPEN_FLAGS_NOINHERIT); /* child shall not see this handle... */1533 rcDbg = DosDupHandle(hPipeW, &hStdOut); assert(!rcDbg); 1534 rcDbg = DosDupHandle(hPipeW, &hStdErr); assert(!rcDbg); 1535 rcDbg = DosClose(hPipeW); assert(!rcDbg); 1536 rcDbg = DosSetFHState(hPipeR, OPEN_FLAGS_NOINHERIT); assert(!rcDbg); 1532 1537 rc = DosExecPgm(szObj, sizeof(szObj), EXEC_ASYNCRESULT, 1533 1538 szArg, pJob->JobInfo.szzEnv, &Res, szArg); 1534 1539 /* Placeholders, prevents clashes... */ 1535 1540 hStdOut = HF_STDOUT; 1536 DosDupHandle(hStdOutSaved, &hStdOut);1541 rcDbg = DosDupHandle(hDummy, &hStdOut); assert(!rcDbg); 1537 1542 hStdErr = HF_STDERR; 1538 DosDupHandle(hStdOutSaved, &hStdErr);1543 rcDbg = DosDupHandle(hDummy, &hStdErr); assert(!rcDbg); 1539 1544 DosReleaseMutexSem(hmtxExec); 1540 1545 … … 1618 1623 pJob->rc = -1; 1619 1624 DosClose(hPipeR); 1625 DosClose(hPipeW); 1620 1626 } 1621 1627 … … 2600 2606 Error("Internal error: failed to get next message from daemon, rc=%d\n", rc); 2601 2607 } 2602 else 2608 else if (!fWait) 2603 2609 Error("Internal error: failed to send message from daemon, rc=%d\n", rc); 2604 2610 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.
