summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2001-01-29 22:31:07 +0000
committerBill Nottingham <notting@redhat.com>2001-01-29 22:31:07 +0000
commit5a6393159db215f4dcaadfa1dc1fb388634bc6ec (patch)
treeaa5e54cf7cba23f0de949d1c6d7ec5d8b83cf8db /src
parentef4bdd963596fc10060be026557ae89234ea3700 (diff)
downloadinitscripts-5a6393159db215f4dcaadfa1dc1fb388634bc6ec.tar.gz
initscripts-5a6393159db215f4dcaadfa1dc1fb388634bc6ec.tar.xz
initscripts-5a6393159db215f4dcaadfa1dc1fb388634bc6ec.zip
add an alarm, so we don't wait forever for input (#23482)
Diffstat (limited to 'src')
-rw-r--r--src/minilogd.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/minilogd.c b/src/minilogd.c
index 5b62d414..90bce3f8 100644
--- a/src/minilogd.c
+++ b/src/minilogd.c
@@ -25,6 +25,14 @@ static int buflines=0;
int debug;
+int recvsock;
+
+void alarm_handler(int x) {
+ alarm(0);
+ close(recvsock);
+ recvsock = -1;
+}
+
void freeBuffer() {
struct sockaddr_un addr;
int sock;
@@ -61,7 +69,7 @@ void cleanup(int exitcode) {
void runDaemon(int sock) {
struct sockaddr_un addr;
- int x,len,addrlen,recvsock,done=0;
+ int x,len,addrlen,done=0;
char *message;
struct stat s1,s2;
struct pollfd pfds;
@@ -94,7 +102,10 @@ void runDaemon(int sock) {
if ( (x>0) && pfds.revents & (POLLIN | POLLPRI)) {
message = calloc(8192,sizeof(char));
recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen);
+ alarm(2);
+ signal(SIGALRM, alarm_handler);
len = read(recvsock,message,8192);
+ alarm(0);
close(recvsock);
if (len>0) {
if (buflines < 200000) {