mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 23:10:02 +02:00
rx_arping handle sigchld (#691)
* rx_arping pclose gave -1 due to sigchld being ignored, fixed with sig handler doing a wait
This commit is contained in:
parent
532f76ed4f
commit
bc46d0f6ab
@ -30,6 +30,7 @@ This document describes the differences between v7.x.x and v7.0.0
|
||||
|
||||
- moench being made compatible with jungfrau 2.0 boards (jungfrau structure, away from ctb)
|
||||
- eiger febl and feb in versions
|
||||
- fixed rx_arping error
|
||||
- fix hdf5 compilation (detspec fields)
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <signal.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include<sys/wait.h>
|
||||
|
||||
namespace sls {
|
||||
|
||||
@ -16,6 +17,10 @@ namespace sls {
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
#endif
|
||||
|
||||
void func(int signum) {
|
||||
wait(NULL);
|
||||
}
|
||||
|
||||
Arping::Arping() {}
|
||||
|
||||
Arping::~Arping() {
|
||||
@ -44,10 +49,11 @@ pid_t Arping::GetProcessId() const { return childPid; }
|
||||
bool Arping::IsRunning() const { return runningFlag; }
|
||||
|
||||
void Arping::StartProcess() {
|
||||
TestCommands();
|
||||
|
||||
// to prevent zombies from child processes being killed
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
signal(SIGCHLD, func);
|
||||
|
||||
// test once to throw exception if arping failed
|
||||
TestForErrors();
|
||||
|
||||
// Needs to be a fork and udp socket deleted after Listening threads
|
||||
// done running to prevent udp socket cannot bind because of popen
|
||||
@ -90,7 +96,7 @@ void Arping::ProcessExecution() {
|
||||
}
|
||||
}
|
||||
|
||||
void Arping::TestCommands() {
|
||||
void Arping::TestForErrors() {
|
||||
// atleast one interface must be set up
|
||||
if (commands[0].empty()) {
|
||||
throw RuntimeError(
|
||||
@ -116,7 +122,7 @@ std::string Arping::ExecuteCommands() {
|
||||
FILE *sysFile = popen(cmd.c_str(), "r");
|
||||
if (sysFile == NULL) {
|
||||
std::ostringstream os;
|
||||
os << "Could not Arping [" << cmd << " ] : Popen fail";
|
||||
os << "Could not Arping (" << cmd << " ) : Popen fail (" << strerror(errno) << ')';
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -128,7 +134,7 @@ std::string Arping::ExecuteCommands() {
|
||||
// check exit status of command
|
||||
if (pclose(sysFile)) {
|
||||
std::ostringstream os;
|
||||
os << "Could not arping[" << cmd << "] : " << output;
|
||||
os << "Could not arping (" << cmd << ") : " << strerror(errno);
|
||||
return os.str();
|
||||
} else {
|
||||
LOG(logDEBUG) << output;
|
||||
|
@ -28,7 +28,7 @@ class Arping {
|
||||
void StopProcess();
|
||||
|
||||
private:
|
||||
void TestCommands();
|
||||
void TestForErrors();
|
||||
std::string ExecuteCommands();
|
||||
void ProcessExecution();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user