[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

setting standard fds to console in translator libs

From: Moritz Schulte
Subject: setting standard fds to console in translator libs
Date: 23 Aug 2001 22:57:22 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7


i thought about adding a function similar to
libdiskfs/console.c::diskfs_console_stdio() to libnetfs and
libtrivfs. Then, these libs would be a bit more consistent: messages
(and e.g. assertion failures) from the translators would go directly
to the console and wouldn't be lost.

It would be easy to just use the following code (from

          int fd = open ("/dev/console", O_RDWR);

          dup2 (fd, 0);
          dup2 (fd, 1);
          dup2 (fd, 2);
          if (fd > 2)
            close (fd);

and call that function during the init function of the libs.

(This way also user-started translators would be able to display to
console via /dev/console.)

But, it's not that easy, the problem is the following: At least the
exec server can't access /dev/console during bootstrap, since the
translator sitting on that node can't be exec()ed. So, the mach device
'console' would need to be used in that situation (libdiskfs does it
like that).

But, how can i check, wether the current process is the bootstrap exec
server? Propably via getpid() - but all this doesn't seems quite ugly.

Other method: We don't let this remapping of the fds be done
automatically from the init function of the libs, but just provide the
function and let the user call it (perhaps with some flags).

Any ideas/suggestions?

Moritz Schulte <moritz@chaosdorf.de> http://www.chaosdorf.de/moritz/
Debian/GNU supporter - http://www.debian.org/ http://www.gnu.org/
GPG fingerprint = 3A14 3923 15BE FD57 FC06  B501 0841 2D7B 6F98 4199

reply via email to

[Prev in Thread] Current Thread [Next in Thread]