Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad exit code when failing to start server #718

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

Bad exit code when failing to start server #718

michaelrsweet opened this issue May 19, 2004 · 4 comments

Comments

@michaelrsweet
Copy link
Collaborator

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.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Try the attached patch...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

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

@michaelrsweet
Copy link
Collaborator Author

"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;
    
    }
    }

@michaelrsweet
Copy link
Collaborator Author

"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.");

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

No branches or pull requests

1 participant