| 1422 | } |
| 1423 | |
| 1424 | static apr_status_t get_cgi_pid(request_rec *r, cgid_server_conf *conf, pid_t *pid) { |
| 1425 | cgid_req_t req = {0}; |
| 1426 | apr_status_t stat; |
| 1427 | int rc, sd; |
| 1428 | |
| 1429 | rc = connect_to_daemon(&sd, r, conf); |
| 1430 | if (rc != OK) { |
| 1431 | return APR_EGENERAL; |
| 1432 | } |
| 1433 | |
| 1434 | req.req_type = GETPID_REQ; |
| 1435 | req.ppid = parent_pid; |
| 1436 | req.conn_id = r->connection->id; |
| 1437 | |
| 1438 | stat = sock_write(sd, &req, sizeof(req)); |
| 1439 | if (stat != APR_SUCCESS) { |
| 1440 | return stat; |
| 1441 | } |
| 1442 | |
| 1443 | /* wait for pid of script */ |
| 1444 | stat = sock_read(sd, pid, sizeof(*pid)); |
| 1445 | if (stat != APR_SUCCESS) { |
| 1446 | return stat; |
| 1447 | } |
| 1448 | |
| 1449 | /* Don't accept zero as a pid here, calling kill(0, SIGTERM) etc |
| 1450 | * later is unpleasant. */ |
| 1451 | if (*pid == 0) { |
| 1452 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01261) |
| 1453 | "daemon couldn't find CGI process for connection %lu", |
| 1454 | r->connection->id); |
| 1455 | return APR_EGENERAL; |
| 1456 | } |
| 1457 | |
| 1458 | return APR_SUCCESS; |
| 1459 | } |
| 1460 | |
| 1461 | |
| 1462 | static apr_status_t cleanup_script(void *vptr) |
no test coverage detected