changeset 23605:d1d32f318ce9

Fix output redirection for perl plugins on win32.
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 28 Jul 2008 04:49:39 +0000
parents df9e569b8f1f
children e97ff340bbf3
files libpurple/plugins/perl/perl.c
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/perl/perl.c	Mon Jul 28 03:47:14 2008 +0000
+++ b/libpurple/plugins/perl/perl.c	Mon Jul 28 04:49:39 2008 +0000
@@ -267,6 +267,24 @@
 	PL_perl_destruct_level = 1;
 	perl_construct(prober);
 
+/* Fix IO redirection to match where pidgin's is going.
+ * Without this, we lose stdout/stderr unless we redirect to a file */
+#ifdef _WIN32
+{
+	PerlIO* newprlIO = PerlIO_open("CONOUT$", "w");
+	if (newprlIO) {
+		int stdout_fd = PerlIO_fileno(PerlIO_stdout());
+		int stderr_fd = PerlIO_fileno(PerlIO_stderr());
+		PerlIO_close(PerlIO_stdout());
+		PerlIO_close(PerlIO_stderr());
+		PerlLIO_dup2(PerlIO_fileno(newprlIO), stdout_fd);
+		PerlLIO_dup2(PerlIO_fileno(newprlIO), stderr_fd);
+
+		PerlIO_close(newprlIO);
+	}
+}
+#endif
+
 	perl_parse(prober, xs_init, argc, argv, NULL);
 
 	perl_run(prober);