Browse code

port from k r5751, fscanf can fail, fix warning related to recent glibc versions

Henning Westerholt authored on 06/05/2009 13:04:34
Showing 1 changed files
... ...
@@ -133,7 +133,9 @@ int daemonize(char*  name)
133 133
 	if (pid_file!=0){
134 134
 		
135 135
 		if ((pid_stream=fopen(pid_file, "r"))!=NULL){
136
-			fscanf(pid_stream, "%d", &p);
136
+			if (fscanf(pid_stream, "%d", &p) < 0) {
137
+				LM_WARN("could not parse pid file %s\n", pid_file);
138
+			}
137 139
 			fclose(pid_stream);
138 140
 			if (p==-1){
139 141
 				LOG(L_CRIT, "pid file %s exists, but doesn't contain a valid"
... ...
@@ -161,7 +163,9 @@ int daemonize(char*  name)
161 161
 
162 162
 	if (pgid_file!=0){
163 163
 		if ((pid_stream=fopen(pgid_file, "r"))!=NULL){
164
-			fscanf(pid_stream, "%d", &p);
164
+			if (fscanf(pid_stream, "%d", &p) < 0) {
165
+				 LM_WARN("could not parse pgid file %s\n", pgid_file);
166
+			}
165 167
 			fclose(pid_stream);
166 168
 			if (p==-1){
167 169
 				LOG(L_CRIT, "pgid file %s exists, but doesn't contain a valid"