Opened 4 years ago

#334 new defect

spawn() fails to execute .cmd if COMSPEC is set to /bin/sh

Reported by: komh Owned by:
Priority: normal Milestone: libc-0.7
Component: libc Version: 0.6.6
Severity: normal Keywords:
Cc:

Description

Hi/2.

How to reproduce.

set COMSPEC=/bin/sh
spawn spawn_comspec.cmd

The result is

/bin/sh: /C: No such file or directory
spawnvp() = 1

The following are sources of a testcase.

spawn.c

#include <stdio.h>
#include <process.h>

int main( int argc, char *argv[])
{
    int rc;

    if( argc < 2 )
    {
        fprintf( stderr, "Usage: spawn program\n");

        return 1;
    }

    rc = spawnvp( P_WAIT, argv[ 1 ], &argv[ 1 ]);
    printf("spawnvp() = %d\n", rc );
    if( rc == -1 )
        perror("spawnvp()");

    return !!rc;
}

spawn_comspec.cmd

echo hello

Change History (0)

Note: See TracTickets for help on using tickets.