filehandle

Delete currently loaded assembly

泪湿孤枕 提交于 2019-12-04 19:42:01
In my application comes with an uninstaller. Everything is working fine, except that I can't find no way to delete the uninstaller.exe file when it's all done. I tried to copy the current assembly exe into a temp directory, but the file-handle of the original file is still locked. Any ideas? You will need to PInvoke to do this. MoveFileEx has the ability to schedule deleting the file on next reboot. If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. Something like: [return:

Where does Ruby keep track of its open file descriptors?

早过忘川 提交于 2019-12-04 09:13:50
问题 What This Question Is Not About This question is not about how to auto-close a file with File#close or the File#open block syntax. It's a question about where Ruby stores its list of open file descriptors at runtime. The Actual Question If you have a program with open descriptors, but you don't have access to the related File or IO object, how can you find a reference to the currently-open file descriptors? Take this example: filename='/tmp/foo' %x( touch "#{filename}" ) File.open(filename)

Timer that supports overlapped I/O (for IOCP)?

懵懂的女人 提交于 2019-12-04 09:02:49
I need to add timers support in an application based on I/O Completion Ports (IOCP). I would like to avoid the use of a specific thread to manage timers. On Linux, you can create a timer that delivers expiration notifications via a file descriptor (see timerfd.h man), so it's great to use it for example with epoll if your application is based on epoll. On Windows, you can use "waitable timers" with an asynchronous procedure call (ACP) (see http://msdn.microsoft.com/en-us/library/ms686898(v=VS.85).aspx ) If you are interested, kqueue (BSD, Mac OS) supports timers by default (see EVFILT_TIMER).

How to find open global filehandles in a perl program

给你一囗甜甜゛ 提交于 2019-12-04 07:55:26
I just tracked down a problem where I had to close all open filehandles for my Apache cgi script to continue. I traced the problem to Parse::RecDescent. #!/usr/bin/env perl use strict; use warnings; use feature qw/say/; $|++; print "Content-Type: text/plain\n\n"; use Parse::RecDescent; say "$$: pre-fork: ". time; if(my $pid = fork) { # parent say "$$: return immediately: ". time; } else { # child say "$$: kicked off big process: ". time; close STDIN; close STDOUT; close STDERR; # close *{'Parse::RecDescent::ERROR'}; sleep 5; } My question is how do I find all open package filehandles? I know

confusing filehandle in perl

半世苍凉 提交于 2019-12-04 06:07:44
问题 Have been playing with the following script but still couldn't understand the meaning behind the two different "kinds" of filehandle forms. Any insight will be hugely appreciated. #! usr/bin/perl use warnings; use strict; open (FH, "example.txt") or die $!; while (<FH>) { my @line = split (/\t/, $_); { print "@line","\n"; } } The output is as expected: @line array contains elements from line 1,2,3 ... from example.txt . As I was told that open (FH, example.txt) is not as good as open (my $fh,

What is the difference between writing to STDOUT and a filehandle opened to “/dev/tty”?

南笙酒味 提交于 2019-12-03 17:47:30
问题 What are the differences between this two examples? #!/usr/bin/perl use warnings; use 5.012; my $str = "\x{263a}"; open my $tty, '>:encoding(utf8)', '/dev/tty' or die $!; say $tty $str; close $tty; open $tty, '>:bytes', '/dev/tty' or die $!; say $tty $str; close $tty; # ------------------------------------------------------- binmode STDOUT, ':encoding(utf8)' or die $!; say $str; binmode STDOUT, ':bytes' or die $!; say $str; 回答1: The difference is that you are writing to two distinct and (from

What is the preferred cross-platform IPC Perl module?

≯℡__Kan透↙ 提交于 2019-12-03 15:37:38
问题 I want to create a simple IO object that represents a pipe opened to another program to that I can periodically write to another program's STDIN as my app runs. I want it to be bullet-proof (in that it catches all errors) and cross-platform. The best options I can find are: open sub io_read { local $SIG{__WARN__} = sub { }; # Silence warning. open my $pipe, '|-', @_ or die "Cannot exec $_[0]: $!\n"; return $pipe; } Advantages: Cross-platform Simple Disadvantages No $SIG{PIPE} to catch errors

Prevent strings from being interpreted as a file handle

折月煮酒 提交于 2019-12-03 10:40:47
Perl has the feature that strings named like a file handle are taken to be a filehandle: # let this be some nice class I wrote package Input { sub awesome { ... } } So when we do Input->awesome or extra-careful: 'Input'->awesome , the method will get called. Unless: # now somewhere far, far away, in package main, somebody does this: open Input, "<&", \*STDIN or die $!; # normally we'd open to a file This code doesn't even have to be executed, but only be seen by the parser in order to have Perl interpret the string 'Input' as a file handle from now on. Therefore, a method call 'Input'->awesome

Open in Java(TM) Platform SE binary

对着背影说爱祢 提交于 2019-12-03 08:12:00
问题 I tried to delete a file that I have two of, one slightly changed, so I could delete the older one and replace it with the new one I changed. When I tried to delete the file I got the error message 'file in use' where it said the action can't be completed because the file is open in Java(TM) Platform SE binary. How do I close it? 回答1: This is what worked for me (using Windows). It is basically the same procedure as commented by ali haider, but with more details... Using Windows command prompt

What is the difference between writing to STDOUT and a filehandle opened to “/dev/tty”?

喜欢而已 提交于 2019-12-03 06:33:44
What are the differences between this two examples? #!/usr/bin/perl use warnings; use 5.012; my $str = "\x{263a}"; open my $tty, '>:encoding(utf8)', '/dev/tty' or die $!; say $tty $str; close $tty; open $tty, '>:bytes', '/dev/tty' or die $!; say $tty $str; close $tty; # ------------------------------------------------------- binmode STDOUT, ':encoding(utf8)' or die $!; say $str; binmode STDOUT, ':bytes' or die $!; say $str; The difference is that you are writing to two distinct and (from Perl's and your program's point of view) independent file handles. The first one is a file handle opened to