Bad exit code when failing to start server #718

Closed
michaelrsweet opened this Issue May 19, 2004 · 4 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented May 19, 2004

Version: 1.1.20
CUPS.org User: twaugh.redhat

If cupsd fails to bind to a port it wants to listen on it exits with an incorrect exit code.

The cupsd binary forks off the server and waits for SIGUSR1 to indicate that it is up and running. In the mean time it handles exit codes, but exits with the status value it got from wait(). Instead it should use WEXITSTATUS and the WIF* macros.

The reason this is a problem is that exit codes are 8 bits, but wait() status values for normal exit are clear in the low 8 bits.

Attached is a minimal patch to fix it. Really it ought to use WEXITSTATUS and WIF* I think.

Collaborator

michaelrsweet commented May 21, 2004

CUPS.org User: mike

Try the attached patch...

Collaborator

michaelrsweet commented May 21, 2004

CUPS.org User: mike

Fixed in CVS - the anonymous CVS repository will be updated at midnight EST.

Collaborator

michaelrsweet commented May 26, 2004

"cups-startup.patch":

--- cups-1.1.20/scheduler/main.c.startup 2004-05-19 11:12:27.292051852 +0100
+++ cups-1.1.20/scheduler/main.c 2004-05-19 12:08:03.849476548 +0100
@@ -292,7 +292,7 @@
else
fprintf(stderr, "cupsd: Child exited on signal %d!\n", i);

  •  return (i);
    
  •  return (i >= 256) ? i / 256 : i;
    
    }
    }
Collaborator

michaelrsweet commented May 26, 2004

"str718.patch":

Index: main.c

RCS file: /development/cvs/cups/scheduler/main.c,v
retrieving revision 1.116
diff -u -r1.116 main.c
--- main.c 19 Mar 2004 22:19:35 -0000 1.116
+++ main.c 21 May 2004 22:33:55 -0000
@@ -225,14 +225,20 @@
if (wait(&i) < 0)
{
perror("cupsd");

  • i = 1;
  • return (1);
  •  }
    
  •  else if (WIFEXITED(i))
    
  •  {
    
  •    fprintf(stderr, "cupsd: Child exited with status %d!\n", WEXITSTATUS(i));
    
  • return (2);
    }
  •  else if (i >= 256)
    
  •    fprintf(stderr, "cupsd: Child exited with status %d!\n", i / 256);
    
    else
  •    fprintf(stderr, "cupsd: Child exited on signal %d!\n", i);
    
  •  {
    
  •    fprintf(stderr, "cupsd: Child exited on signal %d!\n", WTERMSIG(i));
    
  • return (3);
  •  }
    
  •  return (i);
    
  •  return (0);
    
    }
    }

@@ -1008,11 +1014,12 @@

 if (status)
 {
  •  if (status < 256)
    
  • LogMessage(L_ERROR, "PID %d crashed on signal %d!", pid, status);

  •  if (WIFSTOPPED(status))
    
  • LogMessage(L_ERROR, "PID %d crashed on signal %d!", pid,

  •          WSTOPSIG(status));
    

    else
    LogMessage(L_ERROR, "PID %d stopped with status %d!", pid,

  •          status / 256);
    
  •          WEXITSTATUS(status));
    

    if (LogLevel < L_DEBUG)
    LogMessage(L_INFO, "Hint: Try setting the LogLevel to "debug" to find out more.");

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment