Changeset 2796 for branches


Ignore:
Timestamp:
Aug 28, 2006, 3:19:56 AM (19 years ago)
Author:
bird
Message:

Fixed log problem in fork() child. Fixes #119.

Location:
branches/libc-0.6/src/emx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/ChangeLog.LIBC

    r2795 r2796  
    552006-08-27: knut st. osmundsen <[email protected]>
    66    - libc:
     7
    78        o Corrected DosSetFHState mask. Fixes #118.
    89        o Implemented the new length modifiers for *scanf. Adjusted the length
  • branches/libc-0.6/src/emx/src/lib/sys/logstrict.c

    r2654 r2796  
    6262#include <machine/param.h>
    6363#include <InnoTekLIBC/thread.h>
     64
    6465
    6566#define INCL_BASE
     
    9899*******************************************************************************/
    99100/** Hex digits. */
    100 static const char gszHexDigits[17] = "0123456789abcdef";
     101static const char gszHexDigits[17] = "0123456789abcdef";
    101102/** Uppercase hex digits. */
    102 static const char gszHexDigitsUpper[17] = "0123456789ABCDEF";
     103static const char       gszHexDigitsUpper[17] = "0123456789ABCDEF";
     104/** Pointer to default logger instance. */
     105static __LIBC_PLOGINST  gpDefault;
    103106
    104107
     
    116119static int      __libc_logVSNPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args);
    117120static int      __libc_logSNPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...) __printflike(3, 4);
     121
    118122
    119123
     
    247251            while (i-- > 0)
    248252                DosClose(ah[i]);
     253
     254
     255
     256
     257
     258
     259
     260
    249261        }
    250262    }
     
    263275        int         cch;
    264276
     277
    265278        DosGetInfoBlocks(&pTib, &pPib);
    266279        DosGetDateTime(&dt);
    267 
    268280        cch = __libc_logSNPrintf(pszMsg, CCHTMPMSGBUFFER,
    269281                                 "Opened log at %04d-%02d-%02d %02d:%02d:%02d.%02d\n"
    270                                  "Process ID: %#x (%d) Parent PID: %#x (%d)\n",
     282                                 "Process ID: %#x (%d) Parent PID: %#x (%d)\n",
    271283                                 dt.year, dt.month, dt.day, dt.hours, dt.minutes, dt.seconds, dt.hundredths,
    272                                  (int)pPib->pib_ulpid, (unsigned)pPib->pib_ulpid, (int)pPib->pib_ulppid, (unsigned)pPib->pib_ulppid);
     284                                 (int)pPib->pib_ulpid, (unsigned)pPib->pib_ulpid, (int)pPib->pib_ulppid, (unsigned)pPib->pib_ulppid,
     285                                 (int)pPib->pib_ultype);
    273286        DosWrite(pInst->hFile, pszMsg, cch, &cb);
    274287
     288
    275289        cch = __libc_logSNPrintf(pszMsg, CCHTMPMSGBUFFER,
    276290                                 "Exe hmte  : %#x (",
    277291                                 (unsigned)pPib->pib_hmte);
    278292        DosWrite(pInst->hFile, pszMsg, cch, &cb);
    279         if (DosQueryModuleName(pPib->pib_hmte, CCHTMPMSGBUFFER, pszMsg))
     293        if (DosQueryModuleName(pPib->pib_hmte, CCHTMPMSGBUFFER, pszMsg))
    280294            pszMsg[0] = '\0';
    281295        cch = strlen(pszMsg);
     
    284298        DosWrite(pInst->hFile, pszMsg, cch, &cb);
    285299
     300
    286301        cch = __libc_logSNPrintf(pszMsg, CCHTMPMSGBUFFER,
    287302                                 "First arg : %s\n"
     
    292307        cch = strlen(psz);
    293308        DosWrite(pInst->hFile, psz, cch, &cb);
    294 
    295         char    szMod[CCHMAXPATH];
     309        DosWrite(pInst->hFile, "\n", 1, &cb);
     310
     311        /* The current drive and directory. */
     312        ULONG ulDisk = 0;
     313        ULONG fLogical = 0;
     314        if (!DosQueryCurrentDisk(&ulDisk, &fLogical))
     315        {
     316            cch = __libc_logSNPrintf(pszMsg, CCHTMPMSGBUFFER,
     317                                     "Cur dir   : %c:\\",
     318                                     (char)ulDisk + ('A' - 1));
     319            DosWrite(pInst->hFile, pszMsg, cch, &cb);
     320
     321            ULONG cchDir = CCHTMPMSGBUFFER - 4;
     322            if (DosQueryCurrentDir(ulDisk, (PSZ)pszMsg, &cchDir))
     323                pszMsg[0] = '\0';
     324            cch = strlen(pszMsg);
     325            pszMsg[cch++] = '\n';
     326            DosWrite(pInst->hFile, pszMsg, cch, &cb);
     327        }
     328
     329        /* The CRT module. */
     330        char    szMod[128];
    296331        ULONG   iObj = ~0;
    297332        ULONG   offObj = ~0;
    298333        HMODULE hmod = ~0;
    299334        if (DosQueryModFromEIP(&hmod, &iObj, sizeof(szMod), &szMod[0], &offObj, (uintptr_t)__libc_logInit))
     335
    300336            szMod[0] = '\0';
     337
     338
    301339        cch = __libc_logSNPrintf(pszMsg, CCHTMPMSGBUFFER,
    302                                  "\n"
    303                                  "CRT Module: %s hmod=%#lx\n"
     340                                 "CRT Module: %s hmod=%#lx (",
     341                                 szMod, hmod);
     342        DosWrite(pInst->hFile, pszMsg, cch, &cb);
     343
     344        if (    hmod == NULLHANDLE
     345            ||  DosQueryModuleName(hmod, CCHTMPMSGBUFFER - 4, pszMsg))
     346            pszMsg[0] = '\0';
     347        cch = strlen(pszMsg);
     348        pszMsg[cch++] = ')';
     349        pszMsg[cch++] = '\n';
     350        DosWrite(pInst->hFile, pszMsg, cch, &cb);
     351
     352        cch = __libc_logSNPrintf(pszMsg, CCHTMPMSGBUFFER,
    304353                                 "__libc_logInit: addr %p iObj=%ld offObj=%#lx\n",
    305                                  szMod, hmod, (void *)__libc_logInit, iObj, offObj);
     354                                 (void *)__libc_logInit, iObj, offObj);
    306355        DosWrite(pInst->hFile, pszMsg, cch, &cb);
    307356
    308 
     357        /* column headers */
    309358        cch = __libc_logSNPrintf(pszMsg, CCHTMPMSGBUFFER,
    310359                                 "   Millsecond Timestamp.\n"
     
    436485static void *__libc_logDefault(void)
    437486{
    438     /** Pointer to default logger instance. */
    439     static __LIBC_PLOGINST  pDefault;
    440487    /** Set if we've already tried to init the log, but failed. */
    441488    static int              fAlreadyTried;
    442489
    443     if (pDefault)
    444         return pDefault;
     490    if (pDefault)
     491        return pDefault;
    445492    else if (!fAlreadyTried)
    446493    {
     
    501548        __libc_logSNPrintf(szFilename, sizeof(szFilename), "libc_%04x.log", getPid());
    502549        if (__libc_logInit(&DefInst, 0, &DefGrps, szFilename))
    503             pDefault = &DefInst;
     550            pDefault = &DefInst;
    504551
    505552        /*
     
    509556    }
    510557
    511     return pDefault;
     558    return pDefault;
    512559}
    513560
     
    22102257}
    22112258
     2259
     2260
     2261
     2262
     2263
     2264
     2265
     2266
     2267
     2268
     2269
     2270
     2271
     2272
     2273
     2274
     2275
     2276
     2277
     2278
     2279
     2280
     2281
     2282
     2283
     2284
     2285
     2286
     2287
     2288
     2289
     2290
     2291
     2292
     2293
     2294
     2295
     2296
     2297
     2298
     2299
     2300
     2301
     2302
     2303
     2304
     2305
     2306
     2307
     2308
     2309
     2310
     2311
     2312
     2313
     2314
     2315
     2316
     2317
     2318
     2319
     2320
     2321
     2322
     2323
     2324
     2325
     2326
     2327
     2328
     2329
     2330
     2331
     2332
     2333
     2334
     2335
     2336
     2337
     2338
     2339
     2340
     2341
     2342
     2343
     2344
     2345
     2346
     2347
     2348
     2349
     2350
     2351
     2352
     2353
     2354
     2355
     2356
     2357
     2358
     2359
     2360
     2361
     2362
     2363
     2364
     2365
     2366
     2367
     2368
     2369
     2370
     2371
     2372
     2373
     2374
     2375
     2376
     2377
     2378
     2379
     2380
     2381
     2382
     2383
     2384
     2385
     2386
     2387
     2388
     2389
     2390
     2391
     2392
     2393
     2394
     2395
     2396
     2397
     2398
     2399
     2400
     2401
     2402
     2403
     2404
     2405
     2406
     2407
     2408
     2409
     2410
     2411
     2412
     2413
     2414
     2415
     2416
     2417
     2418
     2419
Note: See TracChangeset for help on using the changeset viewer.