[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: shell32: Make ShellExecute use native file association databases as fallback path (resend)
From:       Alexandre Julliard <julliard () winehq ! org>
Date:       2012-08-28 13:10:09
Message-ID: 87zk5fjh72.fsf () wine ! dyndns ! org
[Download RAW message or body]

Erik van Pienbroek <erik@vanpienbroek.nl> writes:

> +#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
> +static UINT_PTR SHELL_try_native_execute ( const char *openCmd, const char *unixName )
> +{
> +    UINT_PTR retval = SE_ERR_NOASSOC;
> +    pid_t cpid;
> +    struct stat st;
> +
> +    if (stat(openCmd, &st) == -1)
> +    {
> +        TRACE("stat() %s failed: %s\n", openCmd, strerror(errno));
> +        return retval;
> +    }
> +
> +    cpid = fork();
> +    if (!cpid)
> +    {
> +        /* Prevent the situation where the native file association database
> +         * tries to run wine to execute a program and we trigger this fallback
> +         * path again and end up in a recursive loop */
> +        if (getenv("WINE_INSIDE_SHELLEXECUTE"))
> +        {
> +            TRACE("recursive loop detected, not continuing with ShellExecute call\n");
> +            exit(EXIT_SUCCESS);
> +        }
> +        setenv("WINE_INSIDE_SHELLEXECUTE", "1", 0);
> +
> +        TRACE("running %s %s\n", openCmd, unixName);
> +        execlp(openCmd, openCmd, unixName, (char*) NULL);
> +        /* execlp replaces the current process image with a new process image,
> +         * so no code below here should get executed by the forked child */
> +    } else {
> +        int status;
> +        waitpid(cpid, &status, 0);
> +        TRACE("status %x\n", status);
> +        if(!WEXITSTATUS(status))
> +            retval = 33;
> +    }
> +
> +    return retval;
> +}

You want spawnvp(), but that sort of thing should probably go in
winebrowser or something like that, and be configurable.

-- 
Alexandre Julliard
julliard@winehq.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic