Skip to content

Commit

Permalink
fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankkumar committed Nov 14, 2011
1 parent d3049c5 commit 04173e8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions FileHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,12 @@ bool FileHandle::getResult(){

void FileHandle::Action(){
FileOperations();
SendResults();
if(SendResultsVar) SendResults();
}

FileHandle::~FileHandle(){
if(Clean) CleanUp();
}

bool FileHandle::Clean=true;
bool FileHandle::Clean=false;
bool FileHandle::SendResultsVar=true;
1 change: 1 addition & 0 deletions FileHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class FileHandle{
void SendResults();
void CleanUp();
static bool Clean;
static bool SendResultsVar;

bool getResult();
void FileOperations();
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Logs.o : Logs.cpp $(VAR)
clean:
rm *.o main *_execution

*_execution : cpp_execution.cpp java_execution.cpp
*_execution : cpp_execution.cpp java_execution.cpp resources.h
g++ cpp_execution.cpp -o cpp_execution
g++ java_execution.cpp -o java_execution
5 changes: 3 additions & 2 deletions cpp_execution.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "includes.h"
#include "resources.h"
#include "config.h"

pid_t cpid;
void ToPipe(const char* str){
Expand Down Expand Up @@ -49,7 +50,7 @@ int main(int args, char *argv[]){
pid_t ChildProcessId = getpid();
passwd* UserDetails = getpwnam("nobody");
char dir[10];
sprintf(dir, "%s%d/",FILEPATH,FileId);
sprintf(dir, "%s%d/", FILEPATH, FileId);
//ToPipe(dir);
if( chdir(dir) == -1){
printf("%d", errno);
Expand Down Expand Up @@ -114,7 +115,7 @@ int main(int args, char *argv[]){
else { /* Code executed by parent */

struct rusage resourceUsage;
w = wait4 (cpid, &status, 0, &resourceUsage);
w = wait4 (cpid, &status, WUNTRACED | WCONTINUED, &resourceUsage);

gettimeofday(&finish,NULL);
t_sec = finish.tv_sec-start.tv_sec;
Expand Down
1 change: 1 addition & 0 deletions java_execution.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "includes.h"
#include "resources.h"
#include "config.h"

pid_t cpid;
void ToPipe(const char* str){
Expand Down
7 changes: 5 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char* argv[])
int opt;
FileInfoFetchOptionsStruct* FileInfoFetchOptions = new FileInfoFetchOptionsStruct();
FileInfoFetchOptions->Init();
while((opt = getopt(argc, argv, "cbf:p:l:")) != -1){
while((opt = getopt(argc, argv, "ncbf:p:l:")) != -1){
switch(opt){
case 'f':
FileInfoFetchOptions->f=true;
Expand All @@ -56,8 +56,11 @@ int main(int argc, char* argv[])
case 'c':
FileHandle::Clean=true;
break;
case 'n':
FileHandle::SendResultsVar=false;
break;
default: /* '?' */
fprintf(stderr, "Usage: %s [-f fileid | [-p problemcode] [-l language]] [-b]", argv[0]);
fprintf(stderr, "Usage: %s [-f fileid | [-p problemcode] [-l language]] [-b] [-n] [-c]", argv[0]);
exit(EXIT_FAILURE);
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void Java_setResourceLimitWrapper(int TimeLimit, int MemoryLimit){
setResourceLimit(RLIMIT_RSS, 4294967295, 4294967295);
//setResourceLimit(RLIMIT_RTPRIO, 0, 0);
//setResourceLimit(RLIMIT_SIGPENDING, 6144, 6144);
//setResourceLimit(RLIMIT_STACK, 8192, 8192);
setResourceLimit(RLIMIT_STACK, 8192, 8192);
//setResourceLimit(RLIMIT_OFILE, 1, 1); // Dont know what it is??
}

Expand Down

0 comments on commit 04173e8

Please sign in to comment.