New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dup2 on XP #6409
Comments
From mgoland@optonline.netHello guys, I think that perl 5.8 on winXP has a problem with file descripter tables. It fails to properly handle parents STDOUT when I dup2 in the child. Here is my script that runs fine on my FreeBSD box. It properly redirects childs STDOUT to a file , while leaving parents STDOUT to the screen. On an XP box, it redirects both parents and childs STDOUT to a file. Any ideas on how to work around it ?? _____cut script______ #!/usr/bin/perl -w # $? child error use POSIX qw ( :sys_wait_h :unistd_h); my $CHILD_SPAWNED=0; #open a file for childs redirection while( $CHILD_SPAWNED < $CHILD_TO_CREATE ){ print "-------\t\t RUNING $CHILD_CREATED------------\n"; if( $CHILD_CREATED < $MAX_CHILD ){ die "couldnt not spawn: $!" unless defined ( my $PID=fork() ); $CHILD_CREATED++; unless( $PID ){ { exec ("perl count.pl") }; print STDERR "could not exec: $!"; } } $status=waitpid(-1,WNOHANG); if( $status != 0 ){ #some child has exited print "child $status has exited \n"; } print "TOTAL CHILD SPAWNED IS $CHILD_SPAWNED\n"; sub myerrno{ } ____paste script_____ |
From @jkeenanOn Mon Mar 31 12:58:25 2003, mgoland wrote:
In the hope that someone with Win32 access and experience can respond to (And, should someone be curious: No, it didn't get a response when it Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Thu, Dec 01, 2011 at 05:00:10PM -0800, James E Keenan via RT wrote:
I suspect what's happening is the *process* stdout is being modified - C:\Users\tony>perl -MPOSIX=dup2 -le "if (fork) { print STDERR 'before ', -t STDO The workaround is probably IPC::Open[23]. Tony |
@tonycoz isn't the advice to not fork on windows then? |
No. it is use IPC::Open[23]. |
Ideally we'd provide something vaguely like posix_spawn(), though it would really need to be dual-life (there's POSIX::RT::Spawn but that's very limited, and broken) |
Migrated from rt.perl.org#21776 (status was 'open')
Searchable as RT21776$
The text was updated successfully, but these errors were encountered: