diff --git a/uwsgi.c b/uwsgi.c index 00bc1137..98301a90 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -380,6 +380,7 @@ int main(int argc, char *argv[], char *envp[]) { {"logto", required_argument, 0, LONG_ARGS_LOGTO}, {"logdate", no_argument, &uwsgi.logdate, 1}, {"chdir", required_argument, 0, LONG_ARGS_CHDIR}, + {"chdir2", required_argument, 0, LONG_ARGS_CHDIR2}, {"grunt", no_argument, &uwsgi.grunt, 1}, {"no-site", no_argument, &Py_NoSiteFlag, 1}, {"vhost", no_argument, &uwsgi.vhost, 1}, @@ -1459,6 +1460,15 @@ int main(int argc, char *argv[], char *envp[]) { signal(SIGPIPE, (void *) &warn_pipe); +// initialization done + + if (uwsgi.chdir2) { + if (chdir(uwsgi.chdir2)) { + uwsgi_error("chdir()"); + exit(1); + } + } + #ifdef __linux__ if (uwsgi.master_process && uwsgi.no_orphans) { if (prctl(PR_SET_PDEATHSIG, SIGINT)) { @@ -2598,6 +2608,9 @@ void manage_opt(int i, char *optarg) { exit(1); } break; + case LONG_ARGS_CHDIR2: + uwsgi.chdir2 = optarg; + break; #ifdef UWSGI_HTTP case LONG_ARGS_HTTP: uwsgi.http = optarg; diff --git a/uwsgi.h b/uwsgi.h index 2a4d44e3..ada25095 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -164,6 +164,7 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t); #define LONG_ARGS_MODE 17031 #define LONG_ARGS_CHDIR 17032 #define LONG_ARGS_ENV 17033 +#define LONG_ARGS_CHDIR2 17034 @@ -643,6 +644,8 @@ struct uwsgi_server { #endif #endif + + char *chdir2; }; struct uwsgi_cluster_node {