autodriver/autodriver.c
static void cleanup(void) {
    // Kill all of the user's processes
    int ret;
    int try = 0;
    // Send a SIGINT first, and give it a couple of seconds
    ret = kill_processes("-INT");
    while (ret == 0) {
        sleep(SHUTDOWN_GRACE_TIME);
        if (try > MAX_KILL_ATTEMPTS) {
            ERROR("Gave up killing user processes");
            break;  // continue to cleanup with best effort
        }
        ret = kill_processes("-KILL");
        try++;
    }

    // Delete all of the files owned by the user in ~user, /tmp, /var/tmp
    // We are currently in ~user.
    // (Note by @mpandya: the find binary is in /bin in RHEL but in /usr/bin
    // in Ubuntu)
    char *find_args[] = {"find", "/usr/bin/find", ".", "/tmp", "/var/tmp", "-user",
        args.user_info.pw_name, "-delete", NULL};
    if (call_program("/usr/bin/env", find_args) != 0) {
        ERROR("Deleting user's files");
        exit(EXIT_OSERROR);
    }
}
/**
 * @brief Clean up the grading user's state.
 *
 * Kills all processes and deletes all files
 */
@brief Clean up the grading user's state.
Kills all processes and deletes all files
@brief Clean up the grading user ' s state . Kills all processes and deletes all files
static void cleanup(void) {
    int ret;
    int try = 0;
    ret = kill_processes("-INT");
    while (ret == 0) {
        sleep(SHUTDOWN_GRACE_TIME);
        if (try > MAX_KILL_ATTEMPTS) {
            ERROR("Gave up killing user processes");
            break;  
        }
        ret = kill_processes("-KILL");
        try++;
    }
    char *find_args[] = {"find", "/usr/bin/find", ".", "/tmp", "/var/tmp", "-user",
        args.user_info.pw_name, "-delete", NULL};
    if (call_program("/usr/bin/env", find_args) != 0) {
        ERROR("Deleting user's files");
        exit(EXIT_OSERROR);
    }
}
static void cleanup ( void ) { int ret ; int try = 0 ; ret = kill_processes ( " " ) ; while ( ret == 0 ) { sleep ( SHUTDOWN_GRACE_TIME ) ; if ( try > MAX_KILL_ATTEMPTS ) { ERROR ( " " ) ; break ; } ret = kill_processes ( " " ) ; try ++ ; } char * find_args [ ] = { " " , " " , " " , " " , " " , " " , args . user_info . pw_name , " " , NULL } ; if ( call_program ( " " , find_args ) != 0 ) { ERROR ( " " ) ; exit ( EXIT_OSERROR ) ; } }
@brief Clean up the grading user's state.
@brief Clean up the grading user ' s state .
// Kill all of the user's processes // Send a SIGINT first, and give it a couple of seconds // continue to cleanup with best effort // Delete all of the files owned by the user in ~user, /tmp, /var/tmp // We are currently in ~user. // (Note by @mpandya: the find binary is in /bin in RHEL but in /usr/bin // in Ubuntu)