Hello Monks,
I am coding in perl for a While now and I really like it
However I need to make one app now that Does DBuss as a daemon and I aint sure how to do this.
I think I am all off.. I cant seem to get the perl -d function to work how I want it and thus I'll just wonder if anyone can shed some light upon my beacon?
Here is my code:
#!/usr/bin.perl -w
use strict;
use warnings;
use Proc::Daemon;
use Proc::PID::File;
#Use DBus
use Net::DBus;
use Net::DBus::Service;
use Net::DBus::Reactor;
use Net::DBus::Exporter qw(com.analyse);
Proc::Daemon::Init();
if (Proc::PID::File->running()) { exit(0); }
#Do Init
my @stack = ();
my $pid = fork();
if(!defined $pid)
{
print "Can't Fork\n";
#Write to Log
}
elsif ($pid == 0)
{
#Child
for(;;)
{
#Listern here to new thing to connect to my DBus?
sleep 1;
}
}
else
{
#MasterProcess
my $Master_Bus = Net::DBus->session();
my $service = $Master_Bus->export_service("com.analyse");
my $object = DBusEnvelope->new($service);
for(;;)
{
#Add New Data from DBus to the Stack var and Execute the next one f
+rom stack in the script.
my $react = Net::DBus::Reactor->main(); #I think I;;need to make a
+function called Main now.. but I aitn sure.
$react->run();
#exec ./script -argv [ pop(@stack) ];
sleep 1;
}
#waitpid($pid,0);
}
Can anyone help me fix this DBus/Daemon thing?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.