Re: File Buffering
Peter and Michael, Your advice seems to have done the trick. Have a great weekend. Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters USA Central Time Zone 636-922-9158 ext. 8652 fax 636-447-4471 [EMAIL PROTECTED] www.nisc.cc - Original Message - From: "Peter Guzis" <[EMAIL PROTECTED]> To: "Dirk Bremer (NISC)" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, October 01, 2004 15:44 Subject: RE: File Buffering > select YOURFILEHANDLE; > $| = 1; > > # enjoy unbuffered file goodness > > -Original Message- > From: Dirk Bremer (NISC) [mailto:[EMAIL PROTECTED] > Sent: Friday, October 01, 2004 1:28 PM > To: [EMAIL PROTECTED] > Subject: File Buffering > > > I wrote and use a module that provides a standardized logging mechanism to > STDOUT and to a defined log file. I have several Perl programs that run all > of the time and use this module. The log file is opened at the program start > and closed at the program end. There is nothing particularly fancy or > complicated with the way that the module opens, writes, or closes the file. > The file is created as a normal text file and regular print functions are > used to write to it. > > While a given program is running an writing to the log file, the log file > can be opened in Notepad and the contents examined. Herein lies the issue, > the program seems to lag behind in the writes to the log file based upon the > known program activity, i.e. there are entries I expect to see in the log > file that are not there, but after a period of time, the log file will catch > up and I will see the results. All entries to the log file are timestamped > so that I know when events occurred. > > I thing that there is some kind of file buffering going on here, i.e. the > log entries are in a file buffer that has not been flushed to the file. The > file is using a specific file handle, i.e. it is not being written to STDOUT > or STDERR. > > I have never really understood the buffering mechanism as employed by Perl > and could use some knowledge in this area. Specifically, how can I force > every write to the log file to be unbuffered? Is the problem with buffering > or is there something else I should look at? > > Note: Using Perl 5.6.1 on Win2K. > > Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters > USA Central Time Zone > 636-922-9158 ext. 8652 fax 636-447-4471 > > [EMAIL PROTECTED] > www.nisc.cc > > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: File Buffering
select YOURFILEHANDLE; $| = 1; # enjoy unbuffered file goodness -Original Message- From: Dirk Bremer (NISC) [mailto:[EMAIL PROTECTED] Sent: Friday, October 01, 2004 1:28 PM To: [EMAIL PROTECTED] Subject: File Buffering I wrote and use a module that provides a standardized logging mechanism to STDOUT and to a defined log file. I have several Perl programs that run all of the time and use this module. The log file is opened at the program start and closed at the program end. There is nothing particularly fancy or complicated with the way that the module opens, writes, or closes the file. The file is created as a normal text file and regular print functions are used to write to it. While a given program is running an writing to the log file, the log file can be opened in Notepad and the contents examined. Herein lies the issue, the program seems to lag behind in the writes to the log file based upon the known program activity, i.e. there are entries I expect to see in the log file that are not there, but after a period of time, the log file will catch up and I will see the results. All entries to the log file are timestamped so that I know when events occurred. I thing that there is some kind of file buffering going on here, i.e. the log entries are in a file buffer that has not been flushed to the file. The file is using a specific file handle, i.e. it is not being written to STDOUT or STDERR. I have never really understood the buffering mechanism as employed by Perl and could use some knowledge in this area. Specifically, how can I force every write to the log file to be unbuffered? Is the problem with buffering or is there something else I should look at? Note: Using Perl 5.6.1 on Win2K. Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters USA Central Time Zone 636-922-9158 ext. 8652 fax 636-447-4471 [EMAIL PROTECTED] www.nisc.cc ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
File Buffering
I wrote and use a module that provides a standardized logging mechanism to STDOUT and to a defined log file. I have several Perl programs that run all of the time and use this module. The log file is opened at the program start and closed at the program end. There is nothing particularly fancy or complicated with the way that the module opens, writes, or closes the file. The file is created as a normal text file and regular print functions are used to write to it. While a given program is running an writing to the log file, the log file can be opened in Notepad and the contents examined. Herein lies the issue, the program seems to lag behind in the writes to the log file based upon the known program activity, i.e. there are entries I expect to see in the log file that are not there, but after a period of time, the log file will catch up and I will see the results. All entries to the log file are timestamped so that I know when events occurred. I thing that there is some kind of file buffering going on here, i.e. the log entries are in a file buffer that has not been flushed to the file. The file is using a specific file handle, i.e. it is not being written to STDOUT or STDERR. I have never really understood the buffering mechanism as employed by Perl and could use some knowledge in this area. Specifically, how can I force every write to the log file to be unbuffered? Is the problem with buffering or is there something else I should look at? Note: Using Perl 5.6.1 on Win2K. Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters USA Central Time Zone 636-922-9158 ext. 8652 fax 636-447-4471 [EMAIL PROTECTED] www.nisc.cc ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Process::Create Sillyness!
For there to be a deficiency with this particular aspect of Win32::Process::Create, there would also need to be a deficiency with the underlying CreateProcess() Win32 API. The actual cause here is the omission of "notepad" in the $appname argument. Win32::Process::Create($obj,$appname,$cmdline,$iflags,$cflags,$curdir) Creates a new process. Args: $objcontainer for process object $appnamefull path name of executable module $cmdlinecommand line args $iflags flag: inherit calling processes handles or not $cflags flags for creation (see exported vars below) $curdir working dir of new process Returns non-zero on success, 0 on failure. ## example from Win32::Process docs Win32::Process::Create($ProcessObj, "C:\\winnt\\system32\\notepad.exe", "notepad temp.txt", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); -Original Message- From: Erik Felton [mailto:[EMAIL PROTECTED] Sent: Friday, October 01, 2004 12:08 PM To: perl-win32-users Subject: Win32::Process::Create Sillyness! Hello, I've checked the mailing list archive on active state and I can find no reference of my issue ever being mentioned. If it has, I apologize in advance for covering old ground. Anyway, I just found what IMHO is a deficiency with Win32::Process::Create. The 3 parameter (arguments passed to the executable) needs to have a leading space. Otherwise, as far as I can tell, the argument is ignored. For Example, here is some code that is basically copied from the document page http://aspn.activestate.com/ASPN/docs/ActivePerl/site/lib/Win32/Process. html This code will not work. It will merely open Notepad with a blank document. - use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create($ProcessObj, "C:\\windows\\system32\\notepad.exe", "c:\\helloworld.txt", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); $ProcessObj->Wait(INFINITE); - This code, on the other hand, will open the hellowworld.txt file. - use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create($ProcessObj, "C:\\windows\\system32\\notepad.exe", " c:\\helloworld.txt", #NOTE, leading space 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); $ProcessObj->Wait(INFINITE); - Can someone explain to me why Win32::Process::Create behaves this way? Thank you Erik Felton ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Win32::Process::Create Sillyness!
Hello, I've checked the mailing list archive on active state and I can find no reference of my issue ever being mentioned. If it has, I apologize in advance for covering old ground. Anyway, I just found what IMHO is a deficiency with Win32::Process::Create. The 3 parameter (arguments passed to the executable) needs to have a leading space. Otherwise, as far as I can tell, the argument is ignored. For Example, here is some code that is basically copied from the document page http://aspn.activestate.com/ASPN/docs/ActivePerl/site/lib/Win32/Process. html This code will not work. It will merely open Notepad with a blank document. - use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create($ProcessObj, "C:\\windows\\system32\\notepad.exe", "c:\\helloworld.txt", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); $ProcessObj->Wait(INFINITE); - This code, on the other hand, will open the hellowworld.txt file. - use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create($ProcessObj, "C:\\windows\\system32\\notepad.exe", " c:\\helloworld.txt", #NOTE, leading space 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); $ProcessObj->Wait(INFINITE); - Can someone explain to me why Win32::Process::Create behaves this way? Thank you Erik Felton ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Simple threading has large handle leak (need help)
After compiling and testing on 5.8.5 this handle leak and memory usage issue has been resolved. Ben -Original Message- From: Ben Conrad [mailto:[EMAIL PROTECTED] Sent: Monday, September 13, 2004 11:52 AM To: Perl-Win32-Users Subject: Simple threading has large handle leak (need help) Hello, - perl v5.8.3/v5.8.4 built for MSWin32-x86-multi-thread - WinXP SP1 + SP2 I'm using a very simple example from the 5.8 perlthrtut and seem to be running into a memory leak of some kind. When I run: # use threads; while (1) { $thr = threads->new(\&sub1); $thr->join; sleep 2; } sub sub1 { print "In the thread\n"; } # When in an infinite loop the memory for the perl process skyrockets using lots of handles even though it only gets to 2 concurrent threads at the same time: Name Pid Pri Thd HndMem User Time Kernel Time Elapsed Time perl3404 8 2 534 184720 0:00:12.125 0:00:00.515 0:00:13.781 The same thing happens when I "sleep 2" after the join, it' just takes longer for the memory to creep. Am I not closing the thread correctly, the tutorial says that $thr->join() will do all OS cleanup for the thread. Thanks, Ben Ben Conrad Sr. Network Administrator 180 Old Colony Avenue Quincy, MA 02170 Passkey International, Inc. [T] 617.237.8225 [M] 617.852.6206 [F] 617.328.1461 http://www.passkey.com *The Key to Optimizing Your Group Performance* ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: How to compile 5.8.5 on Windows?
I finally got this working with the free Borland compiler. Basic steps: - get dmake, set for Borland - Set makefile.mk in .\win32 dir to use Borland env - copy brcc32.exe to rc.exe in Borland .\Bin directory make -v make -v install ...Overall, a painful process for me. Ben -Original Message- From: Ben Conrad [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 10:09 AM To: perl-win32-users Subject: How to compile 5.8.5 on Windows? Folks, I'm trying to compile the latest perl (5.8.5) for Win32. I'm having some issues with the proper steps to get this going, here is what I've done so far. - read: http://search.cpan.org/~nwclark/perl-5.8.5/README.win32#Make - Install MinGW with gcc (c:\WinGW) - Install msys, fstab file points to MinGW) - I've got the latest dmake.exe in my path What the heck do I do next? If I run 'dmake.exe -f makefile.mk test' from C:\temp\perl-5.8.5\win32 it bombs with: dmake.exe: Making [.\win32.h] dmake.exe: Making [.\config.h] dmake.exe: Updating [.\config.h], (1090246617 > 1089112560) del /f config.h dmake.exe: Error -- \bin\sh: No such file or directory If I run dmake.exe from the MINGW32 shell it says: $ dmake -f makefile.mk test del /f config.h dmake.exe: Error -- C:/msys/1.0/bin/sh: No such file or directory I do have /bin/sh at: C:\temp\perl-5.8.5\win32>ls -l c:/msys/1.0/bin/sh -rwxr-xr-x 1 2279 everyone 476672 Mar 16 2004 c:/msys/1.0/bin/sh Ben ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs