Exemple #1
0
static int get_process_time(unsigned short pid, unsigned long long *curtime)
{
    struct stat stat_buf;
    int rc = stat_pid(pid, &stat_buf);
    if (0 != rc) {
        return -1;
    }

    *curtime = stat_buf.st_mtim.tv_sec * 1000000000;
    *curtime += stat_buf.st_mtim.tv_nsec;
    return 0;
}
int trace_get_process_time(pid_t pid, trace_ts_t *curtime)
{
    if (NULL == curtime) {
        errno = EFAULT;
        return -1;
    }

    struct stat stat_buf;
    int rc = stat_pid(pid, &stat_buf);
    if (0 != rc) {
        set_esrch_if_necessary();
        return -1;
    }

    *curtime = stat_buf.st_ctim.tv_sec * TRACE_SECOND + stat_buf.st_ctim.tv_nsec;
    return 0;
}