summaryrefslogtreecommitdiffstats
path: root/login-utils
diff options
context:
space:
mode:
Diffstat (limited to 'login-utils')
-rw-r--r--login-utils/su-common.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index e004e22cf..b153909c8 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -288,18 +288,22 @@ static void create_watching_parent(struct su_context *su)
struct sigaction oldact[3];
int status = 0;
- memset(oldact, 0, sizeof(oldact));
-
- child = fork();
- if (child == (pid_t) - 1) {
+ switch ((int) (child = fork())) {
+ case -1: /* error */
supam_cleanup(su, PAM_ABORT);
err(EXIT_FAILURE, _("cannot create child process"));
- }
+ break;
- /* the child proceeds to run the shell */
- if (child == 0)
+ case 0: /* child */
return;
+ default: /* parent */
+ break;
+ }
+
+ memset(oldact, 0, sizeof(oldact));
+
+
/* In the parent watch the child. */
/* su without pam support does not have a helper that keeps