File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,11 @@ spawn(PyObject *self UNUSED, PyObject *args) {
106106 sigset_t signals ; sigemptyset (& signals );
107107 if (sigprocmask (SIG_SETMASK , & signals , NULL ) != 0 ) exit_on_err ("sigprocmask() in child process failed" );
108108 // Use only signal-safe functions (man 7 signal-safety)
109- if (chdir (cwd ) != 0 ) { if (chdir ("/" ) != 0 ) {} }; // ignore failure to chdir to /
109+ if (chdir (cwd ) != 0 ) {
110+ if (access ("." , X_OK ) != 0 ) { // existing cwd does not exist or dont have permissions for it
111+ if (chdir ("/" ) != 0 ) {} // ignore failure to chdir to /
112+ }
113+ };
110114 if (setsid () == -1 ) exit_on_err ("setsid() in child process failed" );
111115
112116 // Establish the controlling terminal (see man 7 credentials)
You can’t perform that action at this time.
0 commit comments