// File: /workspace/github_cpp_makefile_star2_O1/MUST-Quick-Fry[P]Process-Scheduler/monitor.cpp
// Function: Project::Monitor::Monitor(char**)
Monitor::Monitor(char *command[]):command(command)
{
    int process;
    int status;
    
    start = times(&t_start);
    process = fork();

    if(process < 0){
        status = -1;
    }
    else if(process == 0){ 
        //signal(SIGINT, SIG_DFL); //Default handle every child process
        execvp(command[0],command);
        throw invalid_argument("Fail to execute Child Process!\n");
    }
    else{
        int status;
        set_pid(process);
        signal(SIGTSTP, sig_handler);
        signal(SIGCONT, sig_handler);
        signal(SIGTERM, sig_handler);
        waitpid(process,&status,0);

	// quit loop if the child process has been terminated!
    }
    
     // calculate time
    end = times(&t_end);  
    set_timeElapsed(end-start);
    set_userTime(t_end.tms_cutime);
    set_systermTime(t_end.tms_cstime);
    
    // output 
    cout << endl;        
    cout << endl;
    print_time();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, (%rdi)
xorl %eax, %eax
movl %eax, 0x8(%rdi)
leaq 0x88(%rdi), %r12
xorpd %xmm0, %xmm0
movupd %xmm0, 0x60(%rdi)
movq %rax, 0x70(%rdi)
movq %r12, 0x78(%rdi)
movq %rax, 0x80(%rdi)
movb $0x0, 0x88(%rdi)
movl %eax, 0xa0(%rdi)
addq $0x20, %rdi
callq 0x2390
movq %rax, 0x10(%rbx)
callq 0x20a0
testl %eax, %eax
js 0x42b1
je 0x43b3
movl %eax, %r15d
movl %eax, 0x8(%rbx)
leaq -0x463(%rip), %r14      # 0x3e19
movl $0x14, %edi
movq %r14, %rsi
callq 0x22b0
movl $0x12, %edi
movq %r14, %rsi
callq 0x22b0
movl $0xf, %edi
movq %r14, %rsi
callq 0x22b0
leaq -0x2c(%rbp), %rsi
movl %r15d, %edi
xorl %edx, %edx
callq 0x2220
leaq 0x40(%rbx), %rdi
callq 0x2390
movq %rax, %r14
movq %rax, 0x18(%rbx)
subq 0x10(%rbx), %r14
movl $0x2, %edi
callq 0x2180
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rbx)
xorps %xmm0, %xmm0
cvtsi2sdq 0x50(%rbx), %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x2, %edi
callq 0x2180
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x28(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rbx)
xorps %xmm0, %xmm0
cvtsi2sdq 0x58(%rbx), %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x2, %edi
callq 0x2180
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x28(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x68(%rbx)
movq 0x10c80(%rip), %rdi     # 0x14fc8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq 0x10c65(%rip), %r14     # 0x14fc8
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq 0x10c37(%rip), %rdi     # 0x14fc8
callq 0x2040
movq %rax, %rdi
callq 0x2190
movq %rbx, %rdi
callq 0x4044
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
movq %r14, %rsi
callq 0x2200
movl $0x10, %edi
callq 0x2130
movq %rax, %r15
leaq 0xbcfb(%rip), %rsi      # 0x100cd
movq %rax, %rdi
callq 0x2420
movq 0x10bff(%rip), %rsi     # 0x14fe0
movq 0x10be8(%rip), %rdx     # 0x14fd0
movq %r15, %rdi
callq 0x23c0
movq %rax, %r14
movq %r15, %rdi
callq 0x21d0
jmp 0x4402
jmp 0x43ff
movq %rax, %r14
movq 0x78(%rbx), %rdi
cmpq %r12, %rdi
je 0x4410
callq 0x2250
movq %r14, %rdi
callq 0x23e0