MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / start_children

Function start_children

ffserver.c:435–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433
434
435static 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 }

Callers 1

http_serverFunction · 0.85

Calls 3

http_logFunction · 0.85
av_strlcpyFunction · 0.85
closeFunction · 0.85

Tested by

no test coverage detected