1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-14 14:24:10 +02:00

Preserve cwd after spawn

This commit is contained in:
Brian Fiete 2021-07-15 05:58:59 -07:00
parent 401ab0c98e
commit 8d2b222c1a

View file

@ -844,6 +844,8 @@ BFP_EXPORT BfpSpawn* BFP_CALLTYPE BfpSpawn_Create(const char* inTargetPath, cons
//printf("BfpSpawn_Create: %s %s %x\n", inTargetPath, args, flags); //printf("BfpSpawn_Create: %s %s %x\n", inTargetPath, args, flags);
char* prevWorkingDir = NULL;
if ((workingDir != NULL) && (workingDir[0] != 0)) if ((workingDir != NULL) && (workingDir[0] != 0))
{ {
if (chdir(workingDir) != 0) if (chdir(workingDir) != 0)
@ -852,8 +854,19 @@ BFP_EXPORT BfpSpawn* BFP_CALLTYPE BfpSpawn_Create(const char* inTargetPath, cons
OUTRESULT(BfpSpawnResult_UnknownError); OUTRESULT(BfpSpawnResult_UnknownError);
return NULL; return NULL;
} }
prevWorkingDir = getcwd(NULL, 0);
} }
defer(
{
if (prevWorkingDir != NULL)
{
chdir(prevWorkingDir);
free(prevWorkingDir);
}
});
String newArgs; String newArgs;
String tempFileName; String tempFileName;