added error messages when write fails
This commit is contained in:
parent
363424f15a
commit
c6994e6983
@ -16,13 +16,22 @@
|
||||
|
||||
std::streambuf::int_type sc::io::fdoutbuf::overflow(std::streambuf::int_type c) {
|
||||
if (c != EOF) {
|
||||
if (::write(_fd, &c, 1) != 1) {
|
||||
int res;
|
||||
if ((res = ::write(_fd, &c, 1)) != 1) {
|
||||
return EOF;
|
||||
}
|
||||
else {
|
||||
std::cerr << "write result = " << res << ", errno = " << errno << '\n';
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
std::streamsize sc::io::fdoutbuf::xsputn(const char* s, std::streamsize num) {
|
||||
return ::write(_fd, s, num);
|
||||
int res = ::write(_fd, s, num);
|
||||
if (res != num) {
|
||||
std::cerr << "write result = " << res << ", errno = " << errno << '\n';
|
||||
return EOF;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user