projects
/
runfinite.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add setting environment variables -> fix GL bug
[runfinite.git]
/
src
/
main.cpp
diff --git
a/src/main.cpp
b/src/main.cpp
index c9caf6e6e9def5691f51210495500c92c5a0f02f..3e147b97e4d92056473aec843e43ebab2e35cecb 100644
(file)
--- a/
src/main.cpp
+++ b/
src/main.cpp
@@
-40,7
+40,7
@@
void printUsage(FILE* out, int argc, char** argv)
}
}
-int main(int argc, char*
* argv
)
+int main(int argc, char*
argv[], char* envp[]
)
{
bool argHelp=false;
bool argTime=false;
{
bool argHelp=false;
bool argTime=false;
@@
-151,7
+151,6
@@
int main(int argc, char** argv)
if( pid == 0)
{
char** newargv = (char**) malloc( sizeof(char*)*(argc-fiarg+1) );
if( pid == 0)
{
char** newargv = (char**) malloc( sizeof(char*)*(argc-fiarg+1) );
- char* newenv[] = {NULL};
//Copy arguments
for( int i=fiarg; i<argc; i++)
//Copy arguments
for( int i=fiarg; i<argc; i++)
@@
-163,7
+162,7
@@
int main(int argc, char** argv)
//Execute child process
//Execute child process
- execve(newargv[0], newargv,
newenv
);
+ execve(newargv[0], newargv,
envp
);
perror("execve");
return ERR_EXECVE;
}
perror("execve");
return ERR_EXECVE;
}
@@
-182,10
+181,10
@@
int main(int argc, char** argv)
float loops=0;
//Status flags of child process
int status;
float loops=0;
//Status flags of child process
int status;
- //
100ms
granularity
- const int ussleep=
50
000;
+ //granularity
+ const int ussleep=
25
000;
- do
+ while(true)
{
//Kill the child
if( loops*ussleep/1e6 >= maxtime )
{
//Kill the child
if( loops*ussleep/1e6 >= maxtime )
@@
-197,15
+196,18
@@
int main(int argc, char** argv)
break;
}
break;
}
- //Sleep a round
- usleep(ussleep);
- loops++;
-
//Test for child
if( waitpid(-1, &status, WNOHANG | WUNTRACED | WCONTINUED) < 0 )
break;
//Test for child
if( waitpid(-1, &status, WNOHANG | WUNTRACED | WCONTINUED) < 0 )
break;
- }while( !WIFEXITED(status) );
+ if( WIFEXITED(status) )
+ break;
+
+ //Sleep a round
+ usleep(ussleep);
+ loops++;
+
+ }
}
}