Do not depend on the global 'sockt' being initialized to 0;

instead, use the symbolic constant STDIN_FILENO, as this is
a daemon invoked from inetd.
Remove 'sockt' as it is not referenced.
This commit is contained in:
Bruce M Simpson
2004-06-14 22:43:05 +00:00
parent 9d61853d9f
commit 17d7976856
+2 -3
View File
@@ -72,7 +72,6 @@ static const char rcsid[] =
CTL_MSG request; CTL_MSG request;
CTL_RESPONSE response; CTL_RESPONSE response;
int sockt;
int debug = 0; int debug = 0;
long lastmsgtime; long lastmsgtime;
@@ -122,8 +121,8 @@ main(int argc, char *argv[])
ctl_addr.sa_len = sizeof(ctl_addr); ctl_addr.sa_len = sizeof(ctl_addr);
process_request(mp, &response); process_request(mp, &response);
/* can block here, is this what I want? */ /* can block here, is this what I want? */
cc = sendto(sockt, (char *)&response, sizeof (response), 0, cc = sendto(STDIN_FILENO, (char *)&response,
&ctl_addr, sizeof (ctl_addr)); sizeof (response), 0, &ctl_addr, sizeof (ctl_addr));
if (cc != sizeof (response)) if (cc != sizeof (response))
syslog(LOG_WARNING, "sendto: %m"); syslog(LOG_WARNING, "sendto: %m");
} }