Ignore:
Timestamp:
May 25, 2012, 1:14:22 PM (13 years ago)
Author:
dmik
Message:

kernel32: Cut out hidden kLIBC arguments added by spawn().

These arguments are not intended to be seen by the application and
should not appear in GetCommandLine().

This is a temporary solution (see svn.netlabs.org/libc/ticket/260 for details).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/wprocess.cpp

    r21999 r22000  
    2424#include <stdlib.h>
    2525#include <string.h>
     26
     27#ifdef __KLIBC__
     28#include <klibc/startup.h>
     29#endif
    2630
    2731#include <unicode.h>
     
    16631667        {
    16641668            psz2 = pib_pchcmd + strlen(pib_pchcmd) + 1;
     1669
     1670#ifdef __KLIBC__
     1671            // kLIBC spawn() detects if the process it starts is a kLIBC process
     1672            // and uses special hidden command line arguments to pass additional
     1673            // info to it which are then removed before passing arguments to
     1674            // main(). Since we don't have global argc/argv pointers in kLIBC,
     1675            // we can't access them here and have to cut out these hidden args
     1676            // Yes, it's implementation dependent -- needs to be changed when
     1677            // kLIBC 0.7 (which contains glibal argc/argv) comes out.
     1678            bool isKLIBC = strcmp(psz2, __KLIBC_ARG_SIGNATURE) == 0;
     1679            if (isKLIBC)
     1680                psz2 += strlen(psz2) + 1;
     1681#endif
    16651682            while (*psz2 != '\0')
    16661683            {
     1684#ifdef __KLIBC__
     1685                // if the first byte is a kLIBC flag, skip it
     1686                if (isKLIBC)
     1687                    psz2++;
     1688#endif
    16671689                register int cchTmp = strlen(psz2) + 1; /* + 1 is for terminator (psz). */
    16681690                *psz++ = ' ';           /* add space */
Note: See TracChangeset for help on using the changeset viewer.