VirtualBox

Changeset 1278 in kBuild for trunk/src


Ignore:
Timestamp:
Nov 29, 2007 11:46:50 PM (17 years ago)
Author:
bird
Message:

execvp screws up wrt to anyone waiting on us on window.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk_redirect/kmk_redirect.c

    r1276 r1278  
    5252            "\n"
    5353            "The rwa+tb is like for fopen, if not specified it defaults to w+.\n"
    54             "The <fd> is either a number or an alias for the standard handles;\n" 
     54            "The <fd> is either a number or an alias for the standard handles;\n"
    5555            "i - stdin, o - stdout, e - stderr.\n"
    5656            ,
     
    6060
    6161
    62 int main(int argc, char **argv, char **envp)
     62int main(int argc, char **argv)
    6363{
    6464    int i;
     65#if defined(_MSC_VER)
     66    intptr_t rc;
     67#endif
    6568    FILE *pStdErr = stderr;
    6669    FILE *pStdOut = stdout;
     
    112115            }
    113116
    114             /* 
     117            /*
    115118             * Parse a file descriptor argument.
    116119             */
     
    174177#ifdef O_TEXT
    175178                    fOpen |= O_TEXT;
    176 #endif 
     179#endif
    177180                    psz++;
    178181                    break;
     
    193196                    psz++;
    194197                    break;
    195                        
     198
    196199                case 'e':
    197200                    fd = 2;
    198201                    psz++;
    199202                    break;
    200    
     203
    201204                case '0':
    202205                    if (!psz[1])
     
    220223                        fprintf(pStdErr, "%s: error: failed to convert '%s' to a number\n", argv[0], argv[i]);
    221224                        return 1;
    222                        
     225
    223226                    }
    224227                    if (fd < 0)
     
    258261            if (fd == fileno(pStdErr))
    259262            {
    260                 /* 
     263                /*
    261264                 * Move stderr to a new location, making it close on exec.
    262265                 * If pStdOut has already teamed up with pStdErr, update it too.
     
    270273                }
    271274#ifdef _MSC_VER
    272                 /** @todo figure out how to make the handle close-on-exec. We'll simply close it for now. 
     275                /** @todo figure out how to make the handle close-on-exec. We'll simply close it for now.
    273276                 * SetHandleInformation + set FNOINHERIT in CRT.
    274277                 */
     
    279282                    return 1;
    280283                }
    281 #endif 
     284#endif
    282285
    283286                pNew = fdopen(fdOpened, "w");
     
    335338    }
    336339
    337 #if 0/** @todo defined(_MSC_VER)
    338     / *
    339      * We'll have to find the '--' in the commandline and pass that 
    340      * on to CreateProcess or spawn. Otherwise, the argument qouting 
     340#if defined(_MSC_VER)
     341    /** @todo
     342     * We'll have to find the '--' in the commandline and pass that
     343     * on to CreateProcess or spawn. Otherwise, the argument qouting
    341344     * is gonna be messed up.
    342345     */
     346    if (fileno(pStdErr) != 2)
     347        fclose(pStdErr);
     348    rc = _spawnvp(_P_WAIT, argv[i], &argv[i]);
     349    if (rc == -1 && fileno(pStdErr) != 2)
     350    {
     351        fprintf(pStdErr, "%s: error: _spawnvp(_P_WAIT,%s,..) failed: %s\n", argv[0], argv[i], strerror(errno));
     352        rc = 1;
     353    }
     354    return rc;
    343355#else
    344 # if defined(_MSC_VER) /* tmp hack. */
    345     if (fileno(pStdErr) != 2)
    346     {
    347         fclose(pStdErr);
    348         execv(argv[i], &argv[i]);
    349         return 1;
    350     }
    351 # endif
    352     execv(argv[i], &argv[i]);
    353     fprintf(pStdErr, "%s: error: execv(%s,..) failed: %s\n", argv[0], argv[i], strerror(errno));
    354 #endif
     356    execvp(argv[i], &argv[i]);
    355357    return 1;
     358#endif
    356359}
    357360
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette