| 343 | } |
| 344 | |
| 345 | static apr_status_t run_cgi_child(apr_file_t **script_out, |
| 346 | apr_file_t **script_in, |
| 347 | apr_file_t **script_err, |
| 348 | const char *command, |
| 349 | const char * const argv[], |
| 350 | request_rec *r, |
| 351 | apr_pool_t *p, |
| 352 | cgi_exec_info_t *e_info) |
| 353 | { |
| 354 | const char * const *env; |
| 355 | apr_procattr_t *procattr; |
| 356 | apr_proc_t *procnew; |
| 357 | apr_status_t rc = APR_SUCCESS; |
| 358 | |
| 359 | #ifdef AP_CGI_USE_RLIMIT |
| 360 | core_dir_config *conf = ap_get_core_module_config(r->per_dir_config); |
| 361 | #endif |
| 362 | |
| 363 | #ifdef DEBUG_CGI |
| 364 | #ifdef OS2 |
| 365 | /* Under OS/2 need to use device con. */ |
| 366 | FILE *dbg = fopen("con", "w"); |
| 367 | #else |
| 368 | FILE *dbg = fopen("/dev/tty", "w"); |
| 369 | #endif |
| 370 | int i; |
| 371 | #endif |
| 372 | |
| 373 | RAISE_SIGSTOP(CGI_CHILD); |
| 374 | #ifdef DEBUG_CGI |
| 375 | fprintf(dbg, "Attempting to exec %s as CGI child (argv0 = %s)\n", |
| 376 | r->filename, argv[0]); |
| 377 | #endif |
| 378 | |
| 379 | env = (const char * const *)ap_create_environment(p, r->subprocess_env); |
| 380 | |
| 381 | #ifdef DEBUG_CGI |
| 382 | fprintf(dbg, "Environment: \n"); |
| 383 | for (i = 0; env[i]; ++i) |
| 384 | fprintf(dbg, "'%s'\n", env[i]); |
| 385 | fclose(dbg); |
| 386 | #endif |
| 387 | |
| 388 | /* Transmute ourselves into the script. |
| 389 | * NB only ISINDEX scripts get decoded arguments. |
| 390 | */ |
| 391 | if (((rc = apr_procattr_create(&procattr, p)) != APR_SUCCESS) || |
| 392 | ((rc = apr_procattr_io_set(procattr, |
| 393 | e_info->in_pipe, |
| 394 | e_info->out_pipe, |
| 395 | e_info->err_pipe)) != APR_SUCCESS) || |
| 396 | ((rc = apr_procattr_dir_set(procattr, |
| 397 | ap_make_dirstr_parent(r->pool, |
| 398 | r->filename))) != APR_SUCCESS) || |
| 399 | #if defined(RLIMIT_CPU) && defined(AP_CGI_USE_RLIMIT) |
| 400 | ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, |
| 401 | conf->limit_cpu)) != APR_SUCCESS) || |
| 402 | #endif |
no test coverage detected