Blob Blame History Raw
diff --git a/rhnsd.c b/rhnsd.c
index 896b433..6190c0a 100644
--- a/rhnsd.c
+++ b/rhnsd.c
@@ -49,9 +49,6 @@ static int write_pid (const char *file);
 static void print_version (FILE *stream, struct argp_state *state);
 void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
 
-/* Current rhn_check pid */
-pid_t rhn_check_pid;
-
 /* Definitions of arguments for argp functions.  */
 static const struct argp_option options[] =
 {
@@ -148,34 +145,16 @@ int main (int argc, char **argv)
     if (!foreground) {
 	int i;
 
-	    pid_t pid;
-        pid = fork();
-        if (pid < 0)
-	        exit (EXIT_FAILURE);
-
-        if (pid > 0)
-            exit(EXIT_SUCCESS);
-
+	if (fork ())
+	    exit (0);
 
 	for (i = 0; i < getdtablesize(); i++)
 	    close (i);
 
-	/* read from /dev/null */
-	int devnull = open("/dev/null", O_RDONLY);
-	if ((devnull >= 0) && (devnull != STDIN_FILENO)) {
-	    dup2(devnull, STDIN_FILENO);
-	    close(devnull);
-	}
-
-        pid = fork();
-        if (pid < 0)
-            exit (EXIT_FAILURE);
-
-        if (pid > 0)
-            exit(EXIT_SUCCESS);
+	if (fork ())
+	    exit (0);
 
-        if (setsid() < 0)
-            exit(EXIT_FAILURE);
+	setsid();
 
 	chdir ("/");
 
@@ -273,13 +252,11 @@ Written by %s.\n\
 static void termination_handler (int signum)
 {
     syslog(LOG_NOTICE, "Exiting");
-    /* Send SIGTERM to current running rhn_check
-     * and wait for it to exit. */
-    kill(rhn_check_pid, SIGTERM);
-    wait(NULL);
+
     /* Clean up pid file.  */
     unlink (_PATH_RHNDPID);
-    exit(EXIT_SUCCESS);
+
+    exit (EXIT_SUCCESS);
 }
 
 /* Returns 1 if the process in pid file FILE is running, 0 if not.  */
@@ -417,11 +394,10 @@ static int rhn_do_action(void)
 	openlog("rhnsd", LOG_CONS | LOG_ODELAY | LOG_PID, LOG_DAEMON);
 
 	/* syslog for safekeeping */
-	syslog(LOG_NOTICE, "running program %s with PID %d", RHN_CHECK, getpid());
+	syslog(LOG_DEBUG, "running program %s", RHN_CHECK);
 
         unset_signal_handlers ();
         /* exec binary helper */
-        rhn_check_pid = getpid();
         args[0] = RHN_CHECK;
         execv(RHN_CHECK, args);
 
@@ -431,7 +407,6 @@ static int rhn_do_action(void)
                strerror(errno));
         exit(errno);
     } else if (child > 0) {
-        set_signal_handlers();
 	int ret = 1;
 	char *buf, buffer[10];
 	int bufsize = 0;
diff --git a/rhnsd.init b/rhnsd.init
index dead8bf..ee3e811 100644
--- a/rhnsd.init
+++ b/rhnsd.init
@@ -53,7 +53,7 @@ start() {
 
 stop() {
     echo -n $"Stopping Spacewalk Daemon: "
-    killproc rhnsd -TERM
+    killproc rhnsd
     RETVAL=$?
     echo
     if [ $RETVAL -eq 0 ]; then
diff --git a/rhnsd.spec b/rhnsd.spec
index 42ad138..2a192f6 100644
--- a/rhnsd.spec
+++ b/rhnsd.spec
@@ -5,7 +5,7 @@ Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.
 URL:     https://fedorahosted.org/spacewalk
 Name: rhnsd
 Version: 5.0.13
-Release: 8%{?dist}
+Release: 9%{?dist}
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires: gettext
@@ -138,6 +138,12 @@ rm -fr $RPM_BUILD_ROOT
 %doc LICENSE
 
 %changelog
+* Mon Oct 09 2017 Tomas Kasparek <tkasparek@redhat.com> 5.0.13-9
+- Related: #1499793 - revert previous reboot loop changes
+  (tkasparek@redhat.com)
+- Resolves: #1499793 - Revert "1260527 RHEL7 rhnsd reload doesn't work"
+  (tkasparek@redhat.com)
+
 * Wed Sep 20 2017 Tomas Kasparek <tkasparek@redhat.com> 5.0.13-8
 - Resolves: #1480306 - change permissions for rhnsd.pid (grinrag@gmail.com)
 - Resolves: #1489989 - umask(0) does not reset to default umask