From 2465b38916bab07970490537fa9958e2aaa98b52 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Tue, 30 Mar 2021 21:21:30 -0400 Subject: [PATCH] commentary. --- Ample/PreferencesWindowController.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Ample/PreferencesWindowController.m b/Ample/PreferencesWindowController.m index 007e404..a2cbedd 100644 --- a/Ample/PreferencesWindowController.m +++ b/Ample/PreferencesWindowController.m @@ -176,13 +176,15 @@ const char* args_chmod[] = {"+s", cp, NULL}; // well ... the second command executes a lot more consistently when the (optional) fp is provided and the we fgets the buffer. + // textmate does a wait() to wait for a child to exit. Using the fp (which is popened()?) and reading until EOF + // accomplishes the same thing. myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, "/usr/sbin/chown", kAuthorizationFlagDefaults, (char**)args_chown, &fp); - fgets(buffer, sizeof(buffer), fp); + while (fgets(buffer, sizeof(buffer), fp)); fclose(fp); // fprintf(stderr, "myStatus = %d\ndata: %s\n", myStatus, buffer); myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, "/bin/chmod", kAuthorizationFlagDefaults, (char**)args_chmod, &fp); - fgets(buffer, sizeof(buffer), fp); + while (fgets(buffer, sizeof(buffer), fp)); fclose(fp); // fprintf(stderr, "myStatus = %d\ndata: %s\n", myStatus, buffer);