mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-21 08:29:41 +00:00
terminal session: return number of bytes written
To better support non-blocking terminal components, let the 'Terminal::Session::write()' function return the number of bytes actually written. Fixes #2240
This commit is contained in:
committed by
Norman Feske
parent
9f7a4feab4
commit
dbb641d44a
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Genode Labs GmbH
|
||||
* Copyright (C) 2013-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
@ -183,14 +183,22 @@ namespace Terminal {
|
||||
return num_bytes;
|
||||
}
|
||||
|
||||
void _write(Genode::size_t num_bytes)
|
||||
Genode::size_t _write(Genode::size_t num_bytes)
|
||||
{
|
||||
/* sanitize argument */
|
||||
num_bytes = Genode::min(num_bytes, _io_buffer.size());
|
||||
|
||||
/* write data to descriptor */
|
||||
if (::write(fd(), _io_buffer.local_addr<char>(), num_bytes) < 0)
|
||||
ssize_t written_bytes = ::write(fd(),
|
||||
_io_buffer.local_addr<char>(),
|
||||
num_bytes);
|
||||
|
||||
if (written_bytes < 0) {
|
||||
Genode::error("write error, dropping data");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return written_bytes;
|
||||
}
|
||||
|
||||
Genode::Dataspace_capability _dataspace()
|
||||
|
Reference in New Issue
Block a user