Esempio n. 1
0
bool stdin_fd_tracker_is_stdin(int target) {
    pthread_mutex_lock(&storage_mutex);
    intset_t* fds = get_storage();
    bool is = intset_contains(fds, target);
    pthread_mutex_unlock(&storage_mutex);
    return is;
}
Esempio n. 2
0
void stdin_fd_tracker_did_close(int target) {
    pthread_mutex_lock(&storage_mutex);
    intset_t* fds = get_storage();
    if (intset_contains(fds, target)) {
        D("removing %d\n as dup of stdin", target);
        remove_from_intset(fds, target);
    }
    pthread_mutex_unlock(&storage_mutex);
}
Esempio n. 3
0
void stdin_fd_tracker_did_dup(int orig, int dup) {
    pthread_mutex_lock(&storage_mutex);
    intset_t* fds = get_storage();
    if (intset_contains(fds, orig)) {
        D("adding %d as dup of %d\n", dup, orig);
        add_to_intset(fds, dup);
    }
    pthread_mutex_unlock(&storage_mutex);
}
Esempio n. 4
0
void add_to_intset(intset_t* is, int i) {
    if (intset_contains(is, i) == false) {
        if (is->capacity == is->size) {
            is->capacity += grow_factor;
            is->ints = realloc(is->ints, is->capacity);
            if (is->ints == NULL) die("reallocation of ints failed");
        }
        is->ints[is->size++] = i;
    }
}