[SR-Dev] git:master: port from k r5751, fscanf can fail, fix warning related to recent glibc versions

Henning Westerholt henning.westerholt at 1und1.de
Wed May 6 15:08:29 CEST 2009


Module: sip-router
Branch: master
Commit: 5dbe4f22ddc81c67cebe89c072cbffc0daf3aecd
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5dbe4f22ddc81c67cebe89c072cbffc0daf3aecd

Author: Henning Westerholt <henning.westerholt at 1und1.de>
Committer: Henning Westerholt <henning.westerholt at 1und1.de>
Date:   Wed May  6 15:04:34 2009 +0200

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

---

 daemonize.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/daemonize.c b/daemonize.c
index 03552be..e87bec2 100644
--- a/daemonize.c
+++ b/daemonize.c
@@ -133,7 +133,9 @@ int daemonize(char*  name)
 	if (pid_file!=0){
 		
 		if ((pid_stream=fopen(pid_file, "r"))!=NULL){
-			fscanf(pid_stream, "%d", &p);
+			if (fscanf(pid_stream, "%d", &p) < 0) {
+				LM_WARN("could not parse pid file %s\n", pid_file);
+			}
 			fclose(pid_stream);
 			if (p==-1){
 				LOG(L_CRIT, "pid file %s exists, but doesn't contain a valid"
@@ -161,7 +163,9 @@ int daemonize(char*  name)
 
 	if (pgid_file!=0){
 		if ((pid_stream=fopen(pgid_file, "r"))!=NULL){
-			fscanf(pid_stream, "%d", &p);
+			if (fscanf(pid_stream, "%d", &p) < 0) {
+				 LM_WARN("could not parse pgid file %s\n", pgid_file);
+			}
 			fclose(pid_stream);
 			if (p==-1){
 				LOG(L_CRIT, "pgid file %s exists, but doesn't contain a valid"




More information about the sr-dev mailing list