/* Timeout API for single-threaded programs that use blocking * syscalls (read/write/send/recv/connect/accept). * * Copyright (C) 2017 Red Hat, Inc. * * Author: Stefan Hajnoczi <stefanha@redhat.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. */ /* Use the following pattern: * * timeout_begin(TIMEOUT); * do { * ret = accept(...); * timeout_check("accept"); * } while (ret < 0 && ret == EINTR); * timeout_end(); */ #include <stdlib.h> #include <stdbool.h> #include <unistd.h> #include <stdio.h> #include "timeout.h" static volatile bool timeout; /* SIGALRM handler function. Do not use sleep(2), alarm(2), or * setitimer(2) while using this API - they may interfere with each * other. */
void sigalrm(int signo) { timeout = true; }Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stefan Hajnoczi | 12 | 100.00% | 1 | 100.00% |
Total | 12 | 100.00% | 1 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Stefan Hajnoczi | 14 | 100.00% | 1 | 100.00% |
Total | 14 | 100.00% | 1 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Stefan Hajnoczi | 30 | 100.00% | 1 | 100.00% |
Total | 30 | 100.00% | 1 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Stefan Hajnoczi | 16 | 100.00% | 1 | 100.00% |
Total | 16 | 100.00% | 1 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Stefan Hajnoczi | 98 | 100.00% | 1 | 100.00% |
Total | 98 | 100.00% | 1 | 100.00% |