diff libpurple/plugins/perl/perl.c @ 23650: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 ab5b9acebde3
children fb86dbeb2b15
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);