/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
+ * Revision 1.57 2001/11/16 00:47:43 jongfoster
+ * Changing the tty-disconnection code to use setsid().
+ *
+ * Revision 1.56 2001/11/13 20:20:54 jongfoster
+ * Tabs->spaces, fixing a bug with missing {} around an if()
+ *
+ * Revision 1.55 2001/11/13 20:14:53 jongfoster
+ * Patch for FreeBSD setpgrp() as suggested by Alexander Lazic
+ *
* Revision 1.54 2001/11/07 00:03:14 steudten
* Give reliable return value if an error
* occurs not just 0 with new daemon mode.
* Revision 1.54 2001/11/07 00:03:14 steudten
* Give reliable return value if an error
* occurs not just 0 with new daemon mode.
/* ..or a fast redirect kicked in */
#ifdef FEATURE_FAST_REDIRECTS
|| (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) &&
/* ..or a fast redirect kicked in */
#ifdef FEATURE_FAST_REDIRECTS
|| (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) &&
{
/* Write the answer to the client */
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
{
/* Write the answer to the client */
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0",
csp->ip_addr_str, http->cmd);
}
else
{
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0",
csp->ip_addr_str, http->cmd);
}
else
{
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
csp->ip_addr_str, http->cmd);
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
csp->ip_addr_str, http->cmd);
- if ( *configfile != '/' )
- {
- char *abs_file;
-
- DBG(1, ("configfile before '%s'\n",configfile) );
-
- /* make config-filename absolute here */
- if ( !(basedir = getcwd( NULL, 1024 )))
- {
- perror("get working dir failed");
- exit( 1 );
- }
- DBG(1, ("working dir '%s'\n",basedir) );
- if ( !(abs_file = malloc( strlen( basedir ) + strlen( configfile ) + 5 )))
- {
- perror("malloc failed");
- exit( 1 );
- }
- strcpy( abs_file, basedir );
- strcat( abs_file, "/" );
- strcat( abs_file, configfile );
- configfile = abs_file;
- DBG(1, ("configfile after '%s'\n",configfile) );
- }
+ if ( *configfile != '/' )
+ {
+ char *abs_file;
+
+ DBG(1, ("configfile before '%s'\n",configfile) );
+
+ /* make config-filename absolute here */
+ if ( !(basedir = getcwd( NULL, 1024 )))
+ {
+ perror("get working dir failed");
+ exit( 1 );
+ }
+ DBG(1, ("working dir '%s'\n",basedir) );
+ if ( !(abs_file = malloc( strlen( basedir ) + strlen( configfile ) + 5 )))
+ {
+ perror("malloc failed");
+ exit( 1 );
+ }
+ strcpy( abs_file, basedir );
+ strcat( abs_file, "/" );
+ strcat( abs_file, configfile );
+ configfile = abs_file;
+ DBG(1, ("configfile after '%s'\n",configfile) );
+ }
- pid = fork();
- if ( pid < 0 ) /* error */
- {
- perror("fork");
- exit( 3 );
- }
- else if ( pid != 0 ) /* parent */
- {
- int status;
- pid_t wpid;
- /*
- ** must check for errors
- ** child died due to missing files aso
- */
- sleep( 1 );
- wpid = waitpid( pid, &status, WNOHANG );
- if ( wpid != 0 )
- {
- exit( 1 );
- }
- exit( 0 );
- }
- /* child */
+ pid = fork();
+ if ( pid < 0 ) /* error */
+ {
+ perror("fork");
+ exit( 3 );
+ }
+ else if ( pid != 0 ) /* parent */
+ {
+ int status;
+ pid_t wpid;
+ /*
+ * must check for errors
+ * child died due to missing files aso
+ */
+ sleep( 1 );
+ wpid = waitpid( pid, &status, WNOHANG );
+ if ( wpid != 0 )
+ {
+ exit( 1 );
+ }
+ exit( 0 );
+ }
+ /* child */
+#if 1
+ /* Should be more portable, but not as well tested */
+ setsid();
+#else /* !1 */
-#endif
- fd = open("/dev/tty", O_RDONLY);
- if ( fd )
- {
- /* no error check here */
- ioctl( fd, TIOCNOTTY,0 );
- close ( fd );
- }
- /* should close stderr (fd 2) here too, but the test for existence
- ** and load config file is done in listen_loop() and puts
- ** some messages on stderr there.
- */
+#endif /* ndef __FreeBSD__ */
+ fd = open("/dev/tty", O_RDONLY);
+ if ( fd )
+ {
+ /* no error check here */
+ ioctl( fd, TIOCNOTTY,0 );
+ close ( fd );
+ }
+#endif /* !1 */
+ /* should close stderr (fd 2) here too, but the test for existence
+ ** and load config file is done in listen_loop() and puts
+ ** some messages on stderr there.
+ */