1 #ifndef __JSYSTEM__JPROCESS__
2 #define __JSYSTEM__JPROCESS__
44 execute(
"/bin/tcsh",
"tcsh",
"-i",
"-f");
61 execute(
"/bin/tcsh",
"tcsh",
"-f",
"-c", command.c_str());
76 if (
gIn != NULL) {
delete gIn; }
145 const char* arg1 = (
char*) NULL,
146 const char* arg2 = (
char*) NULL,
147 const char* arg3 = (
char*) NULL,
148 const char* arg4 = (
char*) NULL,
149 const char* arg5 = (
char*) NULL,
150 const char* arg6 = (
char*) NULL,
151 const char* arg7 = (
char*) NULL,
152 const char* arg8 = (
char*) NULL,
153 const char* arg9 = (
char*) NULL)
163 const pid_t pid = fork();
175 close(pipe_stdin [1]);
176 if (dup2 (pipe_stdin [0], STDIN_FILENO) == -1) {
JSystemException(
"dup2-stdin"); }
178 close(pipe_stdout[0]);
179 if (dup2 (pipe_stdout[1], STDOUT_FILENO) == -1) {
JSystemException(
"dup2-stdout"); }
181 close(pipe_stdout[0]);
182 if (dup2 (pipe_stdout[1], STDERR_FILENO) == -1) {
JSystemException(
"dup2-stderr"); }
184 execl(path, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, (
char*) NULL);
193 out = pipe_stdout[0];
194 err = pipe_stderr[0];
196 close(pipe_stdin [0]);
197 close(pipe_stdout[1]);
198 close(pipe_stderr[1]);
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Output file stream buffer.
Exception for creation of fork.
Exception for opening of pipe.
Exception for system call.
Streaming of input and output from Linux command.
JFileOutputStreamBuffer * gIn
JFileInputStreamBuffer * getErrorStreamBuffer(const std::size_t size=65536)
Get pointer to input stream buffer connected to the error output stream.
JFileInputStreamBuffer * getInputStreamBuffer(const std::size_t size=65536)
Get pointer to input stream buffer connected to the normal output stream.
JProcess(const std::string &command)
Constructor.
JProcess & operator=(const JProcess &)
JProcess(const JProcess &)
void execute(const char *path, const char *arg0, const char *arg1=(char *) NULL, const char *arg2=(char *) NULL, const char *arg3=(char *) NULL, const char *arg4=(char *) NULL, const char *arg5=(char *) NULL, const char *arg6=(char *) NULL, const char *arg7=(char *) NULL, const char *arg8=(char *) NULL, const char *arg9=(char *) NULL)
Execute command.
JFileInputStreamBuffer * gErr
JFileInputStreamBuffer * gOut
JProcess()
Default constructor.
JFileOutputStreamBuffer * getOutputStreamBuffer(const std::size_t size=65536)
Get pointer to output stream buffer connected to the normal input stream.
JProcess & operator=(JProcess &&)
void close(std::istream *pf)
Close file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for operating system calls.