Skip to content

Commit

Permalink
fall back to system() in handleSystemCommand: when terminating to avo…
Browse files Browse the repository at this point in the history
…id segfaults

git-svn-id: https://svn.r-project.org/R-packages/trunk/Mac-GUI@7903 694ef91d-65df-0310-b7bb-92e67a308ead
  • Loading branch information
s-u committed Dec 13, 2020
1 parent 42565e6 commit 11ec15e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions RController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1627,14 +1627,25 @@ - (int) handleInstalledPackages: (int) count withNames: (char**) name installedV
return 0;
}

- (int) handleSystemCommand: (char*) cmd
- (int) handleSystemCommand: (const char*) cmd
{
int cstat=-1;
pid_t pid;

// we had issues with fork() and libxpc during cleanup, so fall back to regular system()
// during termination
if (terminating) {
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGALRM, SIG_DFL);
signal(SIGCHLD, SIG_DFL);
return system(cmd);
}

if ([self getRootFlag]) {
FILE *f;
char *argv[3] = { "-c", cmd, 0 };
const char *argv[3] = { "-c", cmd, 0 };
int res;
NSBundle *b = [NSBundle mainBundle];
char *sushPath = 0;
Expand Down
2 changes: 1 addition & 1 deletion REngine/Rcallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
// return value is unused so far
- (int) handleInstalledPackages: (int) count withNames: (char**) name installedVersions: (char**) iver repositoryVersions: (char**) rver update: (BOOL*) stat label: (char*) label;
// its usage is identical to that of the 'system' command
- (int) handleSystemCommand: (char*) cmd;
- (int) handleSystemCommand: (const char*) cmd;
- (int) handleHelpSearch: (int) count withTopics: (char**) topics packages: (char**) pkgs descriptions: (char**) descs urls: (char**) urls title: (char*) title;
- (int) handleCustomPrint: (char*) type withObject: (RSEXP*) obj;
@end
Expand Down

0 comments on commit 11ec15e

Please sign in to comment.