10 #pragma implementation
13 //----------------------------------------------------------------------
14 // Controller-Implementation
15 //----------------------------------------------------------------------
18 // default contstructor
21 SystemcallsSingletoncontroller::SystemcallsSingletoncontroller()
29 // destroy structs for leaving program
30 // open question: should we stop here childs?
31 // Asger says no: I like to have my xdvi open after closing LyX. Maybe
32 // I want to print or something.
34 SystemcallsSingletoncontroller::~SystemcallsSingletoncontroller()
36 ControlledCalls *next;
39 next = SysCalls->next;
47 // Add childprocessinformation into controlled list
51 SystemcallsSingletoncontroller::AddCall(Systemcalls const &newcall)
53 // not yet implemented
54 ControlledCalls *newCall = new ControlledCalls;
55 if (newCall == 0) // sorry, no idea
57 newCall->next = SysCalls;
58 newCall->call = new Systemcalls(newcall);
65 // Check list, if there is a stopped child. If yes, call-back.
69 SystemcallsSingletoncontroller::Timer()
71 // check each entry of our list, if it's finished
72 ControlledCalls *prev = 0;
73 for (ControlledCalls *actCall=SysCalls; actCall; actCall=actCall->next)
75 pid_t pid=actCall->call->Getpid();
77 waitpid(pid, &stat_loc, WNOHANG);
78 if (WIFEXITED(stat_loc) || WIFSIGNALED(stat_loc)) {
79 // Ok, the return value goes into retval.
80 if (WIFEXITED(stat_loc)) {
81 actCall->call->setRetValue(WEXITSTATUS(stat_loc));
83 // Child died, so pretend it returned 1
84 actCall->call->setRetValue(1);
86 // callback and release
87 actCall->call->Callback();
88 if (actCall == SysCalls) {
89 SysCalls = actCall->next;
91 prev->next = actCall->next;