blob: 52b1dc4099f95b8e45a642c1089035d947cd291c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#include <fltk/Widget.h>
#include "inc/DataEntry.h"
#include "inc/SWindow.h"
#include <sys/wait.h>
#include <iostream>
/** *************************************************************
* void runImage runs a Image - building the commandline
* and executes it using system()
***************************************************************/
void runImage(fltk::Widget*, void* p)
{
/* printf("runImage called\n"); */
if ( p == NULL ) {
return;
}
DataEntry& dat = *((DataEntry*) p);
string comm = buildCommand(dat);
/* No command here - faulty session ?!? */
if( comm.empty() ) {
return;
}
pid_t pid;
int status;
pid = fork();
switch( pid ) {
case -1:
cout << "Something went wrong while forking!" << endl;
return;
break;
case 0:
system( comm.c_str() );
exit(0);
break;
default:
if( waitpid( pid, &status, 0 ) == -1 ) {
cerr << "No child with this pid (" << pid << ")" << endl;
}
else {
exit(0);
}
break;
}
}
/**
* Helper-function for runImage(Widget, void) - builds the command
**/
string buildCommand(DataEntry& dat)
{
if (dat.imgtype == VMWARE) {
// run-vmware.sh imagename os(Window-Title) network
return string("/var/X11R6/bin/run-vmware.sh \"/var/lib/vmware/")
.append(dat.imgname)
.append("\" \"")
.append(dat.os)
.append("\" \"")
.append(dat.network)
.append("\"");
}
if(! dat.command.empty() ) {
return dat.command;
}
return string();
}
|