mirror of
https://github.com/QingdaoU/Judger.git
synced 2024-12-28 16:01:41 +00:00
update
This commit is contained in:
parent
bb3c81b812
commit
1afb8f58ef
24
main.c
24
main.c
@ -11,10 +11,11 @@
|
||||
#define WAIT4_FAILED -2
|
||||
|
||||
#define SUCCESS 0
|
||||
#define TIME_LIMIT_EXCEEDED 1
|
||||
#define MEMORY_LIMIT_EXCEEDED 2
|
||||
#define RUNTIME_ERROR 3
|
||||
#define SYSTEM_ERROR 4
|
||||
#define CPU_TIME_LIMIT_EXCEEDED 1
|
||||
#define REAL_TIME_LIMIT_EXCEEDED 2
|
||||
#define MEMORY_LIMIT_EXCEEDED 3
|
||||
#define RUNTIME_ERROR 4
|
||||
#define SYSTEM_ERROR 5
|
||||
|
||||
|
||||
struct result {
|
||||
@ -95,8 +96,11 @@ void judge(struct config *config, struct result *result) {
|
||||
printf("SIGNAL %d\n", signal);
|
||||
#endif
|
||||
result->signal = signal;
|
||||
if (signal == SIGALRM || signal == SIGVTALRM) {
|
||||
result->flag = TIME_LIMIT_EXCEEDED;
|
||||
if (signal == SIGALRM) {
|
||||
result->flag = REAL_TIME_LIMIT_EXCEEDED;
|
||||
}
|
||||
else if (signal == SIGVTALRM) {
|
||||
result->flag = CPU_TIME_LIMIT_EXCEEDED;
|
||||
}
|
||||
else if (signal == SIGSEGV) {
|
||||
if (result->memory > config->max_memory) {
|
||||
@ -121,10 +125,10 @@ void judge(struct config *config, struct result *result) {
|
||||
// cpu time
|
||||
set_timer(config->max_cpu_time / 1000, config->max_cpu_time % 1000, 1);
|
||||
// real time * 3
|
||||
set_timer(config->max_cpu_time / 1000 * 3, 0, 0);
|
||||
set_timer(config->max_cpu_time / 1000 * 3, (config->max_cpu_time % 1000) * 3 % 1000, 0);
|
||||
|
||||
dup2(fileno(fopen(config->in_file, "r")), 0);
|
||||
dup2(fileno(fopen(config->out_file, "w")), 1);
|
||||
//dup2(fileno(fopen(config->in_file, "r")), 0);
|
||||
//dup2(fileno(fopen(config->out_file, "w")), 1);
|
||||
|
||||
execve(config->path, NULL, NULL);
|
||||
}
|
||||
@ -135,7 +139,7 @@ int main() {
|
||||
struct config config;
|
||||
struct result result;
|
||||
|
||||
config.max_cpu_time = 3000;
|
||||
config.max_cpu_time = 2300;
|
||||
config.max_memory = 9000000;
|
||||
|
||||
strcpy(config.path, "/Users/virusdefender/Desktop/judger/test");
|
||||
|
9
test.c
9
test.c
@ -1,15 +1,18 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
char input[1000];
|
||||
scanf("%s", input);
|
||||
printf("%s", input);
|
||||
//scanf("%s", input);
|
||||
//printf("%s", input);
|
||||
printf("Hello world\n");
|
||||
int i = 900000000;
|
||||
while (i) {
|
||||
i = i - 1;
|
||||
}
|
||||
sleep(3);
|
||||
sleep(8);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user