~ubuntu-branches/ubuntu/intrepid/apache2/intrepid

« back to all changes in this revision

Viewing changes to server/mpm_common.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Fritsch
  • Date: 2007-10-18 19:35:40 UTC
  • mfrom: (0.13.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20071018193540-u9bl0154m45xppyj
Tags: 2.2.6-2
* Avoid calling apr_pollset_poll() and accept_func() when the listening
  sockets have already been closed on graceful stop or reload. This
  hopefully fixes processes not being killed (closes: #445263, #447164)
  and the "Bad file descriptor: apr_socket_accept: (client socket)"
  error message (closes: #400918, #443310)
* Allow logresolve to process long lines (Closes: #331631)
* Remove duplicate config examples (Closes: #294662)
* Include README.backtrace describing how to create a backtrace
* Add CVE reference to 2.2.6-1 changelog entry

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
    apr_proc_t proc;
127
127
    apr_status_t waitret;
128
128
 
 
129
    /* Ensure pid sanity. */
 
130
    if (pid < 1) {
 
131
        return 1;
 
132
    }        
 
133
 
129
134
    proc.pid = pid;
130
135
    waitret = apr_proc_wait(&proc, NULL, NULL, APR_NOWAIT);
131
136
    if (waitret != APR_CHILD_NOTDONE) {
305
310
        cur_extra = next;
306
311
    }
307
312
}
 
313
 
 
314
/* Before sending the signal to the pid this function verifies that
 
315
 * the pid is a member of the current process group; either using
 
316
 * apr_proc_wait(), where waitpid() guarantees to fail for non-child
 
317
 * processes; or by using getpgid() directly, if available. */
 
318
apr_status_t ap_mpm_safe_kill(pid_t pid, int sig)
 
319
{
 
320
#ifndef HAVE_GETPGID
 
321
    apr_proc_t proc;
 
322
    apr_status_t rv;
 
323
    apr_exit_why_e why;
 
324
    int status;
 
325
 
 
326
    /* Ensure pid sanity */
 
327
    if (pid < 1) {
 
328
        return APR_EINVAL;
 
329
    }
 
330
 
 
331
    proc.pid = pid;
 
332
    rv = apr_proc_wait(&proc, &status, &why, APR_NOWAIT);
 
333
    if (rv == APR_CHILD_DONE) {
 
334
#ifdef AP_MPM_WANT_PROCESS_CHILD_STATUS
 
335
        /* The child already died - log the termination status if
 
336
         * necessary: */
 
337
        ap_process_child_status(&proc, why, status);
 
338
#endif
 
339
        return APR_EINVAL;
 
340
    }
 
341
    else if (rv != APR_CHILD_NOTDONE) {
 
342
        /* The child is already dead and reaped, or was a bogus pid -
 
343
         * log this either way. */
 
344
        ap_log_error(APLOG_MARK, APLOG_NOTICE, rv, ap_server_conf,
 
345
                     "cannot send signal %d to pid %ld (non-child or "
 
346
                     "already dead)", sig, (long)pid);
 
347
        return APR_EINVAL;
 
348
    }
 
349
#else
 
350
    pid_t pg;
 
351
 
 
352
    /* Ensure pid sanity. */
 
353
    if (pid < 1) {
 
354
        return APR_EINVAL;
 
355
    }
 
356
 
 
357
    pg = getpgid(pid);    
 
358
    if (pg == -1) {
 
359
        /* Process already dead... */
 
360
        return errno;
 
361
    }
 
362
 
 
363
    if (pg != getpgrp()) {
 
364
        ap_log_error(APLOG_MARK, APLOG_ALERT, 0, ap_server_conf,
 
365
                     "refusing to send signal %d to pid %ld outside "
 
366
                     "process group", sig, (long)pid);
 
367
        return APR_EINVAL;
 
368
    }
 
369
#endif        
 
370
 
 
371
    return kill(pid, sig) ? errno : APR_SUCCESS;
 
372
}
308
373
#endif /* AP_MPM_WANT_RECLAIM_CHILD_PROCESSES */
309
374
 
310
375
#ifdef AP_MPM_WANT_WAIT_OR_TIMEOUT
1217
1282
    if (sigaction(SIGILL, &sa, NULL) < 0)
1218
1283
        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, s, "sigaction(SIGILL)");
1219
1284
#endif
 
1285
#ifdef SIGFPE
 
1286
    if (sigaction(SIGFPE, &sa, NULL) < 0)
 
1287
        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, s, "sigaction(SIGFPE)");
 
1288
#endif
1220
1289
 
1221
1290
#else /* NO_USE_SIGACTION */
1222
1291
 
1233
1302
#ifdef SIGILL
1234
1303
    apr_signal(SIGILL, sig_coredump);
1235
1304
#endif /* SIGILL */
 
1305
#ifdef SIGFPE
 
1306
    apr_signal(SIGFPE, sig_coredump);
 
1307
#endif /* SIGFPE */
1236
1308
 
1237
1309
#endif /* NO_USE_SIGACTION */
1238
1310