From 4e1a804cee8f1349967d65118bed03af60c6abdd Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 7 Mar 2010 17:37:48 +0000 Subject: [PATCH] fixed pipe direction, added test sample command --- powersensordaemon/autosample.c | 15 +++++++++------ powersensordaemon/powersensordaemon.c | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/powersensordaemon/autosample.c b/powersensordaemon/autosample.c index 63dd5c8..bcba8c2 100644 --- a/powersensordaemon/autosample.c +++ b/powersensordaemon/autosample.c @@ -51,12 +51,12 @@ int start_autosample_process(options_t* opt) } if (cpid == 0) { - close(pipefd[1]); - return autosample_process(opt, pipefd[0]); + close(pipefd[0]); + return autosample_process(opt, pipefd[1]); } - close(pipefd[0]); - return pipefd[1]; + close(pipefd[1]); + return pipefd[0]; } int autosample_process(options_t *opt, int pipefd) @@ -82,9 +82,12 @@ int autosample_process(options_t *opt, int pipefd) } if(ret == -1) continue; -// if(!ret) { + if(!ret) { // timout has expired... -// } + write(pipefd, "sample temp0", 12); + char c = '\n'; + write(pipefd, &c, 1); + } if(FD_ISSET(sig_fd, &readfds)) { if(signal_handle()) { diff --git a/powersensordaemon/powersensordaemon.c b/powersensordaemon/powersensordaemon.c index f32b571..67158c3 100644 --- a/powersensordaemon/powersensordaemon.c +++ b/powersensordaemon/powersensordaemon.c @@ -465,7 +465,7 @@ int main_loop(int tty_fd, int cmd_listen_fd, int autosample_fd, options_t* opt) if(FD_ISSET(autosample_fd, &tmpfds)) { return_value = nonblock_readline(&autosample_buffer, autosample_fd, &cmd_q, client_lst, opt); if(return_value == 2) { - log_printf(WARNING, "autosample process has crashed, removing pipe to it"); + log_printf(WARNING, "autosample not running, removing pipe to it"); FD_CLR(autosample_fd, &readfds); return_value = 0; continue; -- 1.7.10.4