mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 18:53:09 +02:00
Make system calls restart on signals instead of handling EINTR
This leads to simpler code and probably fewer bugs.
This commit is contained in:
parent
482bd09d78
commit
4550eebc90
@ -140,6 +140,7 @@ static void set_handler(int signal, void (*handler)(int))
|
|||||||
struct sigaction sig;
|
struct sigaction sig;
|
||||||
sigaction(signal, NULL, &sig);
|
sigaction(signal, NULL, &sig);
|
||||||
sig.sa_handler = handler;
|
sig.sa_handler = handler;
|
||||||
|
sig.sa_flags |= SA_RESTART;
|
||||||
sigaction(signal, &sig, NULL);
|
sigaction(signal, &sig, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +116,7 @@ bool writeStringToFile(string const& filename, string const& data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Close temporary file.
|
// Close temporary file.
|
||||||
while (close(fd)) {
|
ok &= close(fd) == 0;
|
||||||
if (errno != EINTR) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace actual output file with temporary file.
|
// Replace actual output file with temporary file.
|
||||||
if (ok) {
|
if (ok) {
|
||||||
@ -148,11 +144,7 @@ bool syncDir(string const& dirname)
|
|||||||
|
|
||||||
bool ok = fsync(fd) == 0;
|
bool ok = fsync(fd) == 0;
|
||||||
|
|
||||||
while (close(fd)) {
|
ok &= close(fd) == 0;
|
||||||
if (errno != EINTR) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user