source: observatorio/simulacion/SimEscenariosEconomicos/process.H

simulacion
Last change on this file was 121b4d6, checked in by Alejandro <amujica@…>, 10 years ago

Wrapper en Python para el svg_builder

  • Property mode set to 100644
File size: 708 bytes
Line 
1# ifndef PROCESS_H
2# define PROCESS_H
3
4# include <unistd.h>
5# include <sys/types.h>
6# include <sys/wait.h>
7
8class Process {
9
10  Process() {
11      // Empty
12  }
13
14  Process(const Process &) {
15      // Empty
16  }
17
18  Process & operator = (const Process &) {
19      return *this;
20  }
21
22public:
23    static int exec(char const * command, char * args[]) {
24
25        int   status = 0;
26
27        pid_t pid;
28
29        pid = fork();
30
31        if (pid < 0) {
32
33            return -1;
34
35        } else if (pid > 0) {
36
37            if (waitpid(pid, &status, 0) != pid) {
38                status = -1;
39            }
40
41        } else  {
42
43            execvp(command, args);
44        }
45
46        return status;
47    }
48};
49
50# endif // PROCESS_H
51
Note: See TracBrowser for help on using the repository browser.