mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
signals: add interruptible usleep
Add small wrapper that temporarily enables signal handling during usleep() and return '0' when interrupted.
This commit is contained in:
parent
bbac843268
commit
941f67ed09
@ -153,3 +153,16 @@ void unblock_signals(void)
|
|||||||
|
|
||||||
_signals_blocked = 0;
|
_signals_blocked = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* usleep with enabled signal handler.
|
||||||
|
* Returns 1 when there was interruption */
|
||||||
|
int interruptible_usleep(useconds_t usec)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
sigint_allow();
|
||||||
|
r = usleep(usec);
|
||||||
|
sigint_restore();
|
||||||
|
|
||||||
|
return (sigint_caught() || r) ? 1 : 0;
|
||||||
|
}
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#ifndef _LVM_SIGNAL_H
|
#ifndef _LVM_SIGNAL_H
|
||||||
#define _LVM_SIGNAL_H
|
#define _LVM_SIGNAL_H
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
void remove_ctrl_c_handler(void);
|
void remove_ctrl_c_handler(void);
|
||||||
void install_ctrl_c_handler(void);
|
void install_ctrl_c_handler(void);
|
||||||
int init_signals(int suppress_messages);
|
int init_signals(int suppress_messages);
|
||||||
@ -28,4 +30,5 @@ void sigint_clear(void);
|
|||||||
void block_signals(uint32_t flags);
|
void block_signals(uint32_t flags);
|
||||||
void unblock_signals(void);
|
void unblock_signals(void);
|
||||||
|
|
||||||
|
int interruptible_usleep(useconds_t usec);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user