void-packages/srcpkgs/noip2/patches/02-fix_foreground.patch

89 lines
2.2 KiB
Diff

--- a/noip2.c.old 2015-01-06 14:47:18.998335680 -0200
+++ b/noip2.c 2015-01-06 14:47:36.957335245 -0200
@@ -134,6 +134,10 @@
+ added -f flag to run in foreground
+ patch suggested by rogi@skylittlesystem.org
+ + January 2015 (dota? =op) version 2.1.9-1
+ + hack to make foreground mode work as expected
+ + patch suggested by rogi@skylittlesystem.org
+
*/
/////////////////////////////////////////////////////////////////////////////
@@ -352,6 +356,7 @@
int debug = 0;
int timed_out = 0;
int background = 1; // new default
+int foreground_hack = 0; // FIXME: hack s2
int port_to_use = CLIENT_IP_PORT;
int socket_fd = -1;
int config_fd = -1;
@@ -744,7 +749,8 @@
shm_dump_active++;
break;
case 'f':
- background=0;
+ background=1;
+ foreground_hack=1;
break;
default:
Usage();
@@ -1031,7 +1037,8 @@
char *err_string;
static int startup = 1;
- x = fork();
+ /* FIXME: hack s2 */
+ x = foreground_hack ? 0 : fork();
switch (x) {
case -1: // error
err_string = strerror(errno);
@@ -1043,13 +1050,23 @@
setsid();
if (get_shm_info() == FATALERR)
return FATALERR;
- log2syslog++;
- if (log2syslog > 0)
- fclose(stderr);
- fclose(stdout);
- fclose(stdin);
- syslog(LOG_INFO, "v%s daemon started%s\n",
- VERSION, (nat) ? " with NAT enabled" : "");
+
+ /* FIXME: hack s2 */
+ if (foreground_hack) {
+ printf("v%s daemon started%s\n",
+ VERSION, (nat) ? " with NAT enabled" : "");
+ }
+
+ else {
+ log2syslog++;
+ if (log2syslog > 0)
+ fclose(stderr);
+ fclose(stdout);
+ fclose(stdin);
+ syslog(LOG_INFO, "v%s daemon started%s\n",
+ VERSION, (nat) ? " with NAT enabled" : "");
+ }
+
while (background) {
delay = MAX(60, my_instance->interval * 60);
if (nat)
@@ -1089,7 +1106,14 @@
if (background) // signal may have reset this!
Sleep(delay);
}
- syslog(LOG_INFO, "v%s daemon ended.\n", VERSION);
+
+ /* FIXME: hack s2 */
+ if (foreground_hack)
+ printf("v%s daemon ended.\n", VERSION);
+
+ else
+ syslog(LOG_INFO, "v%s daemon ended.\n", VERSION);
+
break;
}
return SUCCESS;