Ignore:
Timestamp:
May 24, 2002, 5:39:08 AM (23 years ago)
Author:
bird
Message:

Now does it work....

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/CmdQd/CmdQd.c

    r8482 r8483  
    1 /* $Id: CmdQd.c,v 1.17 2002-05-24 02:41:30 bird Exp $
     1/* $Id: CmdQd.c,v 1.18 2002-05-24 03:39:08 bird Exp $
    22 *
    33 * Command Queue Daemon / Client.
     
    14591459        if (pJob)
    14601460        {
    1461             static BOOL  fStdClosed = FALSE;
    1462             static HFILE hStdOutSaved = -1;
     1461            static HFILE hDummy;
     1462            static BOOL fStdClosed = FALSE;
    14631463            int         rc;
     1464            int         rcDbg;
    14641465            char        szArg[4096];
    14651466            char        szObj[256];
     
    14921493            if (!fStdClosed)
    14931494            {   /* only do this once! */
    1494                 DosDupHandle(HF_STDOUT, &hStdOutSaved);
    1495                 DosSetFHState(hStdOutSaved, OPEN_FLAGS_NOINHERIT); /* child shall not see this handle! */
     1495                HFILE   hf;
    14961496                fclose(stdin);
    14971497                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);
    15061510                fStdClosed = TRUE;
    15071511            }
     
    15141518                return;
    15151519            }
    1516             assert(hPipeW != HF_STDOUT && hPipeR != HF_STDERR);
     1520            assert(hPipeW != HF_STDOUT && hPipeW != HF_STDERR);
     1521            assert(hPipeR != HF_STDOUT && hPipeR != HF_STDERR);
    15171522
    15181523            rc = DosSetDefaultDisk(  pJob->JobInfo.szCurrentDir[0] >= 'a'
     
    15261531                assert(   pJob->JobInfo.szzEnv[pJob->JobInfo.cchEnv-1] == '\0'
    15271532                       && 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);
    15321537                rc = DosExecPgm(szObj, sizeof(szObj), EXEC_ASYNCRESULT,
    15331538                                szArg, pJob->JobInfo.szzEnv, &Res, szArg);
    15341539                /* Placeholders, prevents clashes... */
    15351540                hStdOut = HF_STDOUT;
    1536                 DosDupHandle(hStdOutSaved, &hStdOut);
     1541                rcDbg = DosDupHandle(hDummy, &hStdOut);                     assert(!rcDbg);
    15371542                hStdErr = HF_STDERR;
    1538                 DosDupHandle(hStdOutSaved, &hStdErr);
     1543                rcDbg = DosDupHandle(hDummy, &hStdErr);                     assert(!rcDbg);
    15391544                DosReleaseMutexSem(hmtxExec);
    15401545
     
    16181623                pJob->rc = -1;
    16191624                DosClose(hPipeR);
     1625                DosClose(hPipeW);
    16201626            }
    16211627
     
    26002606            Error("Internal error: failed to get next message from daemon, rc=%d\n", rc);
    26012607    }
    2602     else
     2608    else if (!fWait)
    26032609        Error("Internal error: failed to send message from daemon, rc=%d\n", rc);
    26042610    return rc;
Note: See TracChangeset for help on using the changeset viewer.