Class for launching a new process. More...
#include <Process.hpp>
Class for launching a new process.
Class to launch a process through fork().
Example of usage to run a function:
Example of usage to run a program (i.e., through for()+execvp())
Definition at line 66 of file Process.hpp.
Constructor to run a specific function.
This constructor creates a new process that will run the function given as argument.
Definition at line 70 of file Process.cpp.
Constructor to run a specific program.
This constructor creates a new process that will run the program given as argument. This contructor invokes fork()+execvp().
Definition at line 89 of file Process.cpp.
Function to check if the child has terminated correctly.
This function must be invoked after waitForTermination() and allows to inspect the termination status of the child.
Definition at line 135 of file Process.cpp.
Function to check if the child has terminated for a signal.
This function must be invoked after waitForTermination() and allows to inspect the termination status of the child.
Definition at line 153 of file Process.cpp.
Create a process.
This function creates a new process through fork(). This function is not meant to be called explicitly, but it is automatically called by the constructors.
Definition at line 43 of file Process.cpp.
Get PID of the process related to this instance.
This value is the pid of the new process for both the parent process and the child process (who gets its own pid)
Definition at line 111 of file Process.hpp.
Get current scheduling policy and priority.
Definition at line 249 of file Process.cpp.
Function to send a signal to the process.
This method allows to send a signal to the process related to this instance of Process. This function wraps the classical kill() function. The list of signals is available on /usr/include/bits/signum.h
Definition at line 175 of file Process.cpp.
Set scheduling policy and priority.
Definition at line 229 of file Process.cpp.
Set a handler for a specific signal.
This method allows to manually set a handler for handling a specific signal. The list of signals is available on /usr/include/bits/signum.h Use signals less as possible, mainly for standard situations. During the execution of the handler other signals may arrive. This can lead to inconsistent states. The handler must be short. It must just update the internal state and/or kill the application. Not all library functions can be called inside the handler without having strange behaviors (see man signal). In particular, it's not safe calling functions of the standard library, like printf() or exit(), or other functions defined inside the application itself. The access to global variables is not safe either, unless they have been defined as volatile.
Definition at line 201 of file Process.cpp.
Function to wait the termination of the process.
To avoid deadlocks, this function can be called only by the parent and not by the child itself.
Definition at line 116 of file Process.cpp.
If the class instance is related to the current process.
In a parent-child relationship, this variable is useful to distinguish between the parent and the child. This variable is euql to false for the parent (i.e., the process who created the new process) and equal to true for the child process (i.e., the one who has been created).
Definition at line 85 of file Process.hpp.
Pid of the new process.
This value contains the pid of the new process for both the parent process and the child process (who sees its own pid)
Definition at line 74 of file Process.hpp.
If the process is running.
Definition at line 90 of file Process.hpp.
Exit status of the child process when terminated.
The child process can be terminated by the parent through sendSignal(KILL). The parent can also waith the normal termination of the child through waitForTermination().
Definition at line 99 of file Process.hpp.