hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ProcessHandle.cpp
Go to the documentation of this file.
1 #include <sys/wait.h>
2 #include <sys/types.h>
3 #include <string.h>
4 #include <errno.h>
5 #include <iostream>
6 
7 #include "ProcessHandle.hpp"
8 #include "Process.hpp"
9 
10 namespace HCE
11 {
12 //-----------------------------------------------------------------------------
14 : pid(0)
15 {
16  *this = handle;
17 }
18 //-----------------------------------------------------------------------------
20 {
21  if (this!=&handle)
22  {
23  pid = handle.id();
24  }
25  return *this;
26 }
27 //-----------------------------------------------------------------------------
28 int ProcessHandle::wait(void) const
29 {
30  int rc = 0;
31  int status = 0;
32 
33  do
34  {
35  rc = waitpid(pid, &status, 0);
36  }
37  while (rc < 0 && errno == EINTR);
38 
39  return WEXITSTATUS(status);
40 }
41 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
43 } // end namespace HCE