diff options
Diffstat (limited to 'Source/kwsys/ProcessUNIX.c')
-rw-r--r-- | Source/kwsys/ProcessUNIX.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index fc315a9..96b8300 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -99,6 +99,9 @@ struct kwsysProcess_s /* The timeout length. */ double Timeout; + + /* The working directory for the process. */ + char* WorkingDirectory; /* Time at which the child started. Negative for no timeout. */ kwsysProcessTime StartTime; @@ -207,6 +210,29 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout) } /*--------------------------------------------------------------------------*/ +void kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir) +{ + if(cp->WorkingDirectory == dir) + { + return; + } + if(cp->WorkingDirectory && dir && strcmp(cp->WorkingDirectory, dir) == 0) + { + return; + } + if(cp->WorkingDirectory) + { + free(cp->WorkingDirectory); + cp->WorkingDirectory = 0; + } + if(dir) + { + cp->WorkingDirectory = (char*) malloc(strlen(dir) + 1); + strcpy(cp->WorkingDirectory, dir); + } +} + +/*--------------------------------------------------------------------------*/ int kwsysProcess_GetState(kwsysProcess* cp) { return cp->State; |