summaryrefslogtreecommitdiffabout
path: root/src/eyefiservice.cc
authorMichael Krelin <hacker@klever.net>2011-03-19 17:25:00 (UTC)
committer Michael Krelin <hacker@klever.net>2011-03-19 17:52:04 (UTC)
commit5ca0d6a85c438ea75dc2795aca5176e3b31e89f0 (patch) (unidiff)
treef35c09c1d07c2150d4d0a58a517b878a44591cc8 /src/eyefiservice.cc
parentc295320edf2d733a12a622c5a721c8431800a68a (diff)
downloadiii-5ca0d6a85c438ea75dc2795aca5176e3b31e89f0.zip
iii-5ca0d6a85c438ea75dc2795aca5176e3b31e89f0.tar.gz
iii-5ca0d6a85c438ea75dc2795aca5176e3b31e89f0.tar.bz2
linting debian stuff
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'src/eyefiservice.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyefiservice.cc1
1 files changed, 0 insertions, 1 deletions
diff --git a/src/eyefiservice.cc b/src/eyefiservice.cc
index 49521e0..9650ec1 100644
--- a/src/eyefiservice.cc
+++ b/src/eyefiservice.cc
@@ -1,41 +1,40 @@
1#include <cassert> 1#include <cassert>
2#include <iostream> 2#include <iostream>
3#include <fstream> 3#include <fstream>
4#include <stdexcept> 4#include <stdexcept>
5#include <iterator> 5#include <iterator>
6#include <syslog.h> 6#include <syslog.h>
7#include <sys/wait.h> 7#include <sys/wait.h>
8#include <autosprintf.h> 8#include <autosprintf.h>
9#include <openssl/rand.h>
10#include "eyekinfig.h" 9#include "eyekinfig.h"
11#include "eyetil.h" 10#include "eyetil.h"
12#include "soapeyefiService.h" 11#include "soapeyefiService.h"
13 12
14static binary_t session_nonce; 13static binary_t session_nonce;
15 14
16static bool detached_child() { 15static bool detached_child() {
17 pid_t p = fork(); 16 pid_t p = fork();
18 if(p<0) throw std::runtime_error("failed to fork()"); 17 if(p<0) throw std::runtime_error("failed to fork()");
19 if(!p) { 18 if(!p) {
20 p = fork(); 19 p = fork();
21 if(p<0) { 20 if(p<0) {
22 syslog(LOG_ERR,"Failed to re-fork child process"); 21 syslog(LOG_ERR,"Failed to re-fork child process");
23 _exit(-1); 22 _exit(-1);
24 } 23 }
25 if(!p) { 24 if(!p) {
26 setsid(); 25 setsid();
27 for(int i=getdtablesize();i>=0;--i) close(i); 26 for(int i=getdtablesize();i>=0;--i) close(i);
28 int i=open("/dev/null",O_RDWR); assert(i==0); 27 int i=open("/dev/null",O_RDWR); assert(i==0);
29 i = dup(i); assert(i==1); 28 i = dup(i); assert(i==1);
30 i = dup(i); assert(i==2); 29 i = dup(i); assert(i==2);
31 return true; 30 return true;
32 } 31 }
33 _exit(0); 32 _exit(0);
34 } 33 }
35 int rc; 34 int rc;
36 if(waitpid(p,&rc,0)<0) throw std::runtime_error("failed to waitpid()"); 35 if(waitpid(p,&rc,0)<0) throw std::runtime_error("failed to waitpid()");
37 if(!WIFEXITED(rc)) throw std::runtime_error("error in forked process"); 36 if(!WIFEXITED(rc)) throw std::runtime_error("error in forked process");
38 if(WEXITSTATUS(rc)) throw std::runtime_error("forked process signalled error"); 37 if(WEXITSTATUS(rc)) throw std::runtime_error("forked process signalled error");
39 return false; 38 return false;
40} 39}
41 40