Back to index

python3.2  3.2.2
Functions | Variables
pythonw.c File Reference
#include <Python.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <err.h>
#include <dlfcn.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

static char * get_python_path (void)
int main (int argc, char **argv)

Variables

char ** environ

Function Documentation

static char* get_python_path ( void  ) [static]

Definition at line 57 of file pythonw.c.

{
    size_t len;
    Dl_info info;
    char* end;
    char* g_path;

    if (dladdr(Py_Initialize, &info) == 0) {
        return NULL;
    }

    len = strlen(info.dli_fname);

    g_path = malloc(len+60);
    if (g_path == NULL) {
        return NULL;
    }

    strcpy(g_path, info.dli_fname);
    end = g_path + len - 1;
    while (end != g_path && *end != '/') {
        end --;
    }
    end++;
    if (*end == '.') {
        end++;
    }
    strcpy(end, "Resources/Python.app/Contents/MacOS/" PYTHONFRAMEWORK);

    return g_path;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int argc  ,
char **  argv 
)

Definition at line 151 of file pythonw.c.

                            {
    char* exec_path = get_python_path();

    /*
     * Let argv[0] refer to the new interpreter. This is needed to
     * get the effect we want on OSX 10.5 or earlier. That is, without
     * changing argv[0] the real interpreter won't have access to
     * the Window Server.
     */
    argv[0] = exec_path;

#ifdef HAVE_SPAWN_H
    /* We're weak-linking to posix-spawnv to ensure that
     * an executable build on 10.5 can work on 10.4.
     */
    if (posix_spawn != NULL) {
        posix_spawnattr_t spawnattr = NULL;

        setup_spawnattr(&spawnattr);
        posix_spawn(NULL, exec_path, NULL,
            &spawnattr, argv, environ);
        err(1, "posix_spawn: %s", exec_path);
    }
#endif
    execve(exec_path, argv, environ);
    err(1, "execve: %s", argv[0]);
    /* NOTREACHED */
}

Here is the call graph for this function:


Variable Documentation

char** environ

Definition at line 305 of file os.py.