diff options
author | Lassi Marttala <Lassi.LM.Marttala@partner.bmw.de> | 2013-01-25 13:56:08 +0100 |
---|---|---|
committer | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2013-07-19 16:54:21 +0200 |
commit | 06d85034559e3d7fd7a10e1caaa77fe79bf25a68 (patch) | |
tree | 572c57690f04bcb798dfba9b0b38266283556f3e /src/daemon/dlt-daemon.c | |
parent | 78e1afcc7a1e0f3f7103ee242bdd08c1bef755ee (diff) | |
download | DLT-daemon-06d85034559e3d7fd7a10e1caaa77fe79bf25a68.tar.gz |
Fix compiler warnings
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Diffstat (limited to 'src/daemon/dlt-daemon.c')
-rw-r--r-- | src/daemon/dlt-daemon.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index ca45aab..9405e6e 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -1066,7 +1066,8 @@ void dlt_daemon_signal_handler(int sig) void dlt_daemon_daemonize(int verbose) { - int i,lfp,bytes_written,ret; + int i,lfp; + ssize_t pid_len; PRINT_FUNCTION_VERBOSE(verbose); @@ -1103,14 +1104,17 @@ void dlt_daemon_daemonize(int verbose) /* Open standard descriptors stdin, stdout, stderr */ i=open("/dev/null",O_RDWR); /* open stdin */ - ret=dup(i); /* stdout */ - ret=dup(i); /* stderr */ + if(dup(i) < 0) + dlt_log(LOG_ERR, "Failed to direct stdout to /dev/null.\n");/* stdout */ + if(dup(i) < 0) + dlt_log(LOG_ERR, "Failed to direct stderr to /dev/null.\n"); /* stderr */ /* Set umask */ umask(DLT_DAEMON_UMASK); /* Change to known directory */ - ret=chdir(DLT_USER_DIR); + if(chdir(DLT_USER_DIR) < 0) + dlt_log(LOG_ERR, "Failed to chdir to DLT_USER_DIR.\n");; /* Ensure single copy of daemon; run only one instance at a time */ @@ -1128,7 +1132,9 @@ void dlt_daemon_daemonize(int verbose) /* only first instance continues */ sprintf(str,"%d\n",getpid()); - bytes_written=write(lfp,str,strlen(str)); /* record pid to lockfile */ + pid_len = strlen(str); + if(write(lfp,str,pid_len) != pid_len) /* record pid to lockfile */ + dlt_log(LOG_ERR, "Could not write pid to file in dlt_daemon_daemonize.\n"); /* Catch signals */ signal(SIGCHLD,SIG_IGN); /* ignore child */ |