|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
#include <cstring>
|
|
|
#include <cerrno>
|
|
|
#include <cerrno>
|
|
|
|
|
|
|
|
|
|
|
|
/// Dummy used to suppressed warnings about unused values.
|
|
|
|
|
|
int iDummy;
|
|
|
|
|
|
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send message to parent.
|
|
|
// Send message to parent.
|
|
|
errMsg = "Error redirecting stdin in the child: " + getErrorText();
|
|
|
errMsg = "Error redirecting stdin in the child: " + getErrorText();
|
|
|
::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
|
|
|
|
|
|
iDummy = ::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
exit(-1);
|
|
|
exit(-1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send message to parent.
|
|
|
// Send message to parent.
|
|
|
errMsg = "Error redirecting stdout in the child: " + getErrorText();
|
|
|
errMsg = "Error redirecting stdout in the child: " + getErrorText();
|
|
|
::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
|
|
|
|
|
|
iDummy = ::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
exit(-1);
|
|
|
exit(-1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send message to parent.
|
|
|
// Send message to parent.
|
|
|
errMsg = "Error closing the pipes in the child: " + getErrorText();
|
|
|
errMsg = "Error closing the pipes in the child: " + getErrorText();
|
|
|
::write(STDOUT_FILENO, errMsg.data(), errMsg.size());
|
|
|
|
|
|
|
|
|
iDummy = ::write(STDOUT_FILENO, errMsg.data(), errMsg.size());
|
|
|
exit(-1);
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send message to parent.
|
|
|
// Send message to parent.
|
|
|
errMsg = "Error from exec: " + getErrorText();
|
|
|
errMsg = "Error from exec: " + getErrorText();
|
|
|
::write(STDOUT_FILENO, errMsg.data(), errMsg.size());
|
|
|
|
|
|
|
|
|
iDummy = ::write(STDOUT_FILENO, errMsg.data(), errMsg.size());
|
|
|
exit(-1);
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send message to parent.
|
|
|
// Send message to parent.
|
|
|
errMsg = "Error redirecting stdin in the child: " + getErrorText();
|
|
|
errMsg = "Error redirecting stdin in the child: " + getErrorText();
|
|
|
::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
|
|
|
|
|
|
iDummy = ::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
exit(-1);
|
|
|
exit(-1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send message to parent.
|
|
|
// Send message to parent.
|
|
|
errMsg = "Error redirecting stdout in the child: " + getErrorText();
|
|
|
errMsg = "Error redirecting stdout in the child: " + getErrorText();
|
|
|
::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
|
|
|
|
|
|
iDummy = ::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
exit(-1);
|
|
|
exit(-1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send message to parent.
|
|
|
// Send message to parent.
|
|
|
errMsg = "Error redirecting stderr in the child: " + getErrorText();
|
|
|
errMsg = "Error redirecting stderr in the child: " + getErrorText();
|
|
|
::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
|
|
|
|
|
|
iDummy = ::write(childStdOutPipe[1], errMsg.data(), errMsg.size());
|
|
|
exit(-1);
|
|
|
exit(-1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send message to parent.
|
|
|
// Send message to parent.
|
|
|
errMsg = "Error closing the pipes in the child: " + getErrorText();
|
|
|
errMsg = "Error closing the pipes in the child: " + getErrorText();
|
|
|
::write(STDOUT_FILENO, errMsg.data(), errMsg.size());
|
|
|
|
|
|
|
|
|
iDummy = ::write(STDOUT_FILENO, errMsg.data(), errMsg.size());
|
|
|
exit(-1);
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
errMsg = "Error (from exec) running the command \"";
|
|
|
errMsg = "Error (from exec) running the command \"";
|
|
|
errMsg += execvArgv[0];
|
|
|
errMsg += execvArgv[0];
|
|
|
errMsg += ": " + getErrorText();
|
|
|
errMsg += ": " + getErrorText();
|
|
|
::write(STDOUT_FILENO, errMsg.data(), errMsg.size());
|
|
|
|
|
|
|
|
|
iDummy = ::write(STDOUT_FILENO, errMsg.data(), errMsg.size());
|
|
|
exit(-1);
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|