Hi all,

I am trying to fork a daemon process off whenever a user logs into my web application. I am currently trying to do it using a system call to call a script that does the actual forking, but it doesn't seem to be working. I also can't figure out how to get more visibility into the problem. All I know is when I do a test-login, Dancer seems to go through everything fine, but all I get from the system call is 256. Here's the code from the web app:

sub start_client_handler { my ($user_no) = @_; + my $cmd = '/usr/bin/perl' + . ' /home/username/workspace/Space/bin/start_client_handle +r_daemon.pl' . " $user_no" + . $ENV{IS_TEST} ? ' test' : ''; + system($cmd); }

And here's the code that is supposed to fork the daemon. When I call it by itself (not from my Dancer web app), it seems to work fine. Not sure what's going wrong when I call it from the app...

#!/usr/bin/perl use strict; use warnings; use AnyEvent; use Proc::Daemon; use Space::Handler; my $user_no = shift @ARGV; my $base_dir = '/home/username/workspace/Space'; die "Error: user_no must be provided to the client handler." unless $u +ser_no; $ENV{IS_TEST} = !! grep { lc($_) eq 'test' } @ARGV; $| = 1 if $ENV{IS_TEST}; my $daemon = Proc::Daemon->new( work_dir => "$base_dir/bin", child_STDOUT => "$base_dir/logs/client_handler_$user_no.log", child_STDERR => "+>>$base_dir/logs/errors/client_handler_$user_no. +log", ); $daemon->Init(); my $handler = Space::Handler->new( user_no => $user_no, daemon => $daemon, ); $handler->run(); my $keep_alive = AnyEvent->condvar; $keep_alive->wait;

Any guidance/direction would be much appreciated!


In reply to Does something in Dancer prevent using the system call? by Riales

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.