History

avserver: remove daemon mode

This code spews a multitude of warnings with glibc (unchecked return values), some of them possibly warranted. Furthermore, the deamonisation is not suitable for use with typical startup scripts as it does not provide the PID of the daemon in any way. Users wishing to run avserver as a daemon can still do so using start-stop-daemon or equivalent tools.

Mans Rullgard committed 14 years ago

Commit ada51a31 parent 9eded0f4 files · +2 −48Browse files

Showing the changes to avserver.c (1 of 4 files). Show all

Unified · Split

avserver.c+0−38
@@ -301,12 +301,10 @@ static int rtp_new_av_stream(HTTPContext *c, · 300 unmodified lines
301301 HTTPContext *rtsp_c);
302302
303303 static const char *my_program_name;
304−static const char *my_program_dir;
305304
306305 static const char *config_filename = "/etc/avserver.conf";
307306
308307 static int avserver_debug;
309−static int avserver_daemon;
310308 static int no_launch;
311309 static int need_to_start_children;
312310
@@ -524,9 +522,6 @@ static void start_children(FFStream *feed) · 211 unmodified lines
524522 }
525523 }
526524
527− /* This is needed to make relative pathnames work */
528− chdir(my_program_dir);
529−
530525 signal(SIGPIPE, SIG_DFL);
531526
532527 execvp(pathname, feed->child_argv);
@@ -4081,8 +4076,6 @@ static int parse_ffconfig(const char *filename) · 3548 unmodified lines
40814076 if (resolve_host(&my_http_addr.sin_addr, arg) != 0) {
40824077 ERROR("%s:%d: Invalid host/IP address: %s\n", arg);
40834078 }
4084− } else if (!av_strcasecmp(cmd, "NoDaemon")) {
4085− avserver_daemon = 0;
40864079 } else if (!av_strcasecmp(cmd, "RTSPPort")) {
40874080 get_arg(arg, sizeof(arg), &p);
40884081 val = atoi(arg);
@@ -4655,7 +4648,6 @@ static void handle_child_exit(int sig) · 566 unmodified lines
46554648 static void opt_debug(void)
46564649 {
46574650 avserver_debug = 1;
4658− avserver_daemon = 0;
46594651 logfilename[0] = '-';
46604652 }
46614653
@@ -4686,8 +4678,6 @@ int main(int argc, char **argv) · 24 unmodified lines
46864678 show_banner();
46874679
46884680 my_program_name = argv[0];
4689− my_program_dir = getcwd(0, 0);
4690− avserver_daemon = 1;
46914681
46924682 parse_options(NULL, argc, argv, options, NULL);
46934683
@@ -4719,37 +4709,9 @@ int main(int argc, char **argv) · 25 unmodified lines
47194709
47204710 compute_bandwidth();
47214711
4722− /* put the process in background and detach it from its TTY */
4723− if (avserver_daemon) {
4724− int pid;
4725−
4726− pid = fork();
4727− if (pid < 0) {
4728− perror("fork");
4729− exit(1);
4730− } else if (pid > 0) {
4731− /* parent : exit */
4732− exit(0);
4733− } else {
4734− /* child */
4735− setsid();
4736− close(0);
4737− open("/dev/null", O_RDWR);
4738− if (strcmp(logfilename, "-") != 0) {
4739− close(1);
4740− dup(0);
4741− }
4742− close(2);
4743− dup(0);
4744− }
4745− }
4746−
47474712 /* signal init */
47484713 signal(SIGPIPE, SIG_IGN);
47494714
4750− if (avserver_daemon)
4751− chdir("/");
4752−
47534715 if (http_server() < 0) {
47544716 http_log("Could not start server\n");
47554717 exit(1);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t