Handling EOF on stdin

Norman Feske norman.feske at genode-labs.com
Tue Dec 10 11:28:25 CET 2019


Hi Sid,

> Thank you for your suggestion. While I like the idea of using the terminal size
> {0,0} as a way to communicate end of data, I'm not sure if it's applicable in 
> my case. Let me draw up my scenario in init config snippets:

there are two questions. First, how to communicate the EOF condition
from the terminal server to the terminal client? Second, how to handle
the EOF at the terminal client side (respectively the libc)?

My suggestion referred only to the first one (because your original
question was about how to transport the EOF). You are right that the
second part is still open. In contrast to Noux, the
Vfs::Terminal_file_system [1] does not yet handle EOF.

[1]
https://github.com/genodelabs/genode/blob/master/repos/os/src/lib/vfs/terminal_file_system.h

> So, the way I see it in this case, I'm not really in control of the Terminal 
> client. Or, if I understand you correctly, I would have to change the libc 
> implementation by handling the `size_changed_sigh` and if the new size is {0,0} 
> I would emulate a EOF signal to the jvm. 
> While I'm hesitant changing the Terminal session, I'm even more hesitant to 
> extend libc with this workaround.

Don't be afraid. It's not that bad. ;-) All that is missing is the
handling of the special case of mode (0,0) in the VFS terminal fs linked
above. At the VFS an EOF is signaled to the VFS client (e.g., the libc)
by a successful return of read with 0 characters. I recently implemented
the EOF handling for the VFS pipe plugin and think that the VFS terminal
fs can follow the same pattern.

[2]
https://github.com/genodelabs/genode/blob/master/repos/gems/src/lib/vfs/pipe/plugin.cc

> Just to emphasize my case a bit more. I'm not in control of the 
> Java application. The Java application is expected to handle stdin and stdout in 
> a request/respond kind of way. So the EOF signal from the Java applications 
> perspective is not used to gracefully shutdown itself, but to know when no more 
> data is transferred.
> Does the combination of the posix runtime and a terminal or pipe connection to 
> it not call for a EOF signal?

EOF is not a signal at the libc level. It is just a successful read of 0
characters.

I think that filling the current gap in the vfs/terminal_file_system.h
should perfectly solve your issue. If you are hesitant, I can give it a
go later this week.

Cheers
Norman

-- 
Dr.-Ing. Norman Feske
Genode Labs

https://www.genode-labs.com · https://genode.org

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth



More information about the users mailing list