Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hello tbsky,

Can you give example code for a service you run, together with the command sequence you issue to control service installation, etc.? So far, I’ve not been able to get your code to work — but that’s likely because I don’t know enough about the Win32::Daemon module. :-(

In the meantime, perhaps you could try a module such as Test::LeakTrace. Here’s how I would proceed:

  • Wrap the top-level code into its own subroutine, say sub main
  • Change each exit statement into a return statement; for example, exit 1; becomes return 1;
  • Add the following at the top level:
    use Test::LeakTrace; { my $result; leaktrace { $result = main(); }; exit $result; }
  • Redirect program output to a log file, to facilitate analysis of the leak reports after the service has been stopped and uninstalled.

BTW, the following isn’t very informative:

print "Failed to install service: $!\n";

From the documentation, the correct way to report failure is like this:

print 'Failed to install service: ', Win32::FormatMessage(Win32::Daemon::GetLastError()), "\n";

Also, you have use Fcntl;, but I don’t think it’s actually used anywhere, is it?

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: Win32::Daemon memory leak by Athanasius
in thread win32::daemon memory leak by tbsky

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2023-12-09 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (38 votes). Check out past polls.

    Notices?