Skip to content

Commit

Permalink
backport of the fix for 489019
Browse files Browse the repository at this point in the history
svn path=/branches/mono-2-0/mono/; revision=131136
  • Loading branch information
gonzalop committed Apr 6, 2009
1 parent a5ccd28 commit de606b7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mono/metadata/ChangeLog
@@ -1,3 +1,10 @@
2009-03-27 Gonzalo Paniagua Javier <gonzalo@novell.com>

* appdomain.c:
* console-io.[ch]: added new mono_console_init() to make sure that
file descriptors 0, 1 and 2 are opened.
Bug #489019 fixed.

2009-01-23 Zoltan Varga <vargaz@gmail.com>

Backport of r124266.
Expand Down
2 changes: 2 additions & 0 deletions mono/metadata/appdomain.c
Expand Up @@ -46,6 +46,7 @@
#include <mono/utils/mono-path.h>
#include <mono/utils/mono-stdlib.h>
#include <mono/utils/mono-io-portability.h>
#include <mono/metadata/console-io.h>
#ifdef PLATFORM_WIN32
#include <direct.h>
#endif
Expand Down Expand Up @@ -213,6 +214,7 @@ mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
mono_gc_init ();

mono_network_init ();
mono_console_init ();

/* mscorlib is loaded before we install the load hook */
mono_domain_fire_assembly_load (mono_defaults.corlib->assembly, NULL);
Expand Down
21 changes: 21 additions & 0 deletions mono/metadata/console-io.c
Expand Up @@ -12,6 +12,7 @@
#include <glib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#ifdef HAVE_SYS_TIME_H
Expand Down Expand Up @@ -64,6 +65,26 @@ static gchar *keypad_xmit_str;
static struct termios mono_attr;
#endif

#if defined(PLATFORM_WIN32)
void
mono_console_init (void)
{
}
#else
void
mono_console_init (void)
{
int fd;

/* Make sure the standard file descriptors are opened */
fd = open ("/dev/null", O_RDWR);
while (fd >= 0 && fd < 3) {
fd = open ("/dev/null", O_RDWR);
}
close (fd);
}
#endif

#ifdef PLATFORM_WIN32
MonoBoolean
ves_icall_System_ConsoleDriver_Isatty (HANDLE handle)
Expand Down
1 change: 1 addition & 0 deletions mono/metadata/console-io.h
Expand Up @@ -18,6 +18,7 @@

G_BEGIN_DECLS

void mono_console_init (void) MONO_INTERNAL;
MonoBoolean ves_icall_System_ConsoleDriver_Isatty (HANDLE handle) MONO_INTERNAL;
gint32 ves_icall_System_ConsoleDriver_InternalKeyAvailable (gint32 timeout) MONO_INTERNAL;
MonoBoolean ves_icall_System_ConsoleDriver_SetEcho (MonoBoolean echo) MONO_INTERNAL;
Expand Down

0 comments on commit de606b7

Please sign in to comment.