#!/usr/bin/perl use strict; use warnings; use threads; my $th1 = threads->create(\&run, 1); my $th2 = threads->create(\&run, 2); sleep; exit; sub run { my $num = shift; my ($bus, $service, $purple); eval {$bus = Net::DBus->session}; if ($@) {print "th$num: Error in bus: $@\n"; threads->exit()} eval {$service = $bus->get_service('im.pidgin.purple.PurpleService') }; if ($@) {print "th$num: Error in service: $@\n"; threads->exit()} eval {$purple = $service->get_object('/im/pidgin/purple/PurpleObject', 'im.pidgin.purple.PurpleInterface')}; if ($@) {print "th$num: Error in purple: $@\n"; threads->exit()} eval {$purple->connect_to_signal ('ReceivedImMsg', \&read_cb)}; if ($@) {print "th$num: Error in connect: $@\n"; threads->exit()} eval {Net::DBus::Reactor->main()->run()}; if ($@) {print "th$num: Error in run: $@\n"; threads->exit()} } sub read_cb { print scalar(@_) , ' params', "\n"; }