| 433 | |
| 434 | |
| 435 | static void start_children(FFStream *feed) |
| 436 | { |
| 437 | if (no_launch) |
| 438 | return; |
| 439 | |
| 440 | for (; feed; feed = feed->next) { |
| 441 | if (feed->child_argv && !feed->pid) { |
| 442 | feed->pid_start = time(0); |
| 443 | |
| 444 | feed->pid = fork(); |
| 445 | |
| 446 | if (feed->pid < 0) { |
| 447 | http_log("Unable to create children\n"); |
| 448 | exit(1); |
| 449 | } |
| 450 | if (!feed->pid) { |
| 451 | /* In child */ |
| 452 | char pathname[1024]; |
| 453 | char *slash; |
| 454 | int i; |
| 455 | |
| 456 | av_strlcpy(pathname, my_program_name, sizeof(pathname)); |
| 457 | |
| 458 | slash = strrchr(pathname, '/'); |
| 459 | if (!slash) |
| 460 | slash = pathname; |
| 461 | else |
| 462 | slash++; |
| 463 | strcpy(slash, "ffmpeg"); |
| 464 | |
| 465 | http_log("Launch commandline: "); |
| 466 | http_log("%s ", pathname); |
| 467 | for (i = 1; feed->child_argv[i] && feed->child_argv[i][0]; i++) |
| 468 | http_log("%s ", feed->child_argv[i]); |
| 469 | http_log("\n"); |
| 470 | |
| 471 | for (i = 3; i < 256; i++) |
| 472 | close(i); |
| 473 | |
| 474 | if (!ffserver_debug) { |
| 475 | i = open("/dev/null", O_RDWR); |
| 476 | if (i != -1) { |
| 477 | dup2(i, 0); |
| 478 | dup2(i, 1); |
| 479 | dup2(i, 2); |
| 480 | close(i); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | /* This is needed to make relative pathnames work */ |
| 485 | chdir(my_program_dir); |
| 486 | |
| 487 | signal(SIGPIPE, SIG_DFL); |
| 488 | |
| 489 | execvp(pathname, feed->child_argv); |
| 490 | |
| 491 | _exit(1); |
| 492 | } |
no test coverage detected