Hi, sorry to be late.
I tried with your code but can't reproduce the problem you
mentioned.
the obtained output from the execution was:
% ./waf --run dce-test_sighandler
mySendSignal will search for process 53512 (hard coded, FIXME!!!)
Found a process (ptr 0x1452950), calling UtilsSendSignal with SIGUSR2
%
and files-0/var/log/53512/stdout contains:
Testprogram for sighandler
main loop...
main loop...
main loop...
mySignalHandler received SIGUSR2
Doing a 1second sleep()
(snip)
which version of dce are you using ?
if you're using dce-dev, could you let me know which
revision of ns-3-dce you are using ?
thank you for your time.
-- Hajime
At Wed, 26 Mar 2014 03:08:25 -0700 (PDT),
Thomas Burger wrote:
>
> [1 <multipart/alternative (7bit)>]
> [1.1 <text/plain; UTF-8 (7bit)>]
> --
> You received this message because you are subscribed to the Google Groups "ns-3-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
ns-3-users+...@googlegroups.com.
> To post to this group, send email to
ns-3-...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/ns-3-users.
> For more options, visit
https://groups.google.com/d/optout.
> [1.2 <text/html; UTF-8 (quoted-printable)>]
>
> [2 dce-test_sighandler.cc <text/x-c++src; US-ASCII (7bit)>]
> #include "ns3/core-module.h"
> #include "ns3/dce-module.h"
> #include "../../model/utils.h" //UtilsGetNodeId()
> #include "ns3/node-list.h" //NodeList::GetNode()
> #include <signal.h> //SIGINT
>
> using namespace ns3;
>
> void mySendSignal(int pid)
> {
> //53512
> printf ("mySendSignal will search for process 53512 (hard coded, FIXME!!!)\n"); //FIXME
>
> Ptr<DceManager> dceManager = NodeList::GetNode (0)->GetObject<DceManager> ();
> Process* dceProcess = dceManager->SearchProcess (53512);
> if (dceProcess)
> {
> printf ("Found a process (ptr 0x%x), calling UtilsSendSignal with SIGUSR2\n", (void*)dceProcess);
> UtilsSendSignal (dceProcess, SIGUSR2);
> }
> else
> {
> printf ("dceProcess not found\n");
> NS_ASSERT (false);
> }
> }
>
> int main (int argc, char *argv[])
> {
> NodeContainer nodes;
> nodes.Create (1);
>
> DceManagerHelper dceManager;
> dceManager.Install (nodes);
>
> DceApplicationHelper dce;
> ApplicationContainer apps;
>
> dce.SetStackSize (1<<20);
>
> dce.SetBinary ("test_sighandler");
> dce.ResetArguments ();
> apps = dce.Install (nodes.Get (0));
> apps.Start (Seconds (0.0));
>
> //XXX Why is here a ScheduleWithContext() required?
> // A normal Schedule() leads to SIGSEGV because m_scheduler is NULL pointer (m_scheduler->Enqueue in TaskManager::Wakeup)
> Simulator::ScheduleWithContext (0, Seconds (30), &mySendSignal, 123456789);
>
> Simulator::Stop (Seconds(300.0));
> Simulator::Run ();
> Simulator::Destroy ();
> }
> [3 test_sighandler.c <text/x-csrc; US-ASCII (7bit)>]
> #include <unistd.h>
> #include <stdio.h>
> #include <stdint.h>
> #include <stdlib.h> //EXIT_FAILURE
> #include <signal.h>
>
> void mySignalHandler(int signo)
> {
>
> if (signo == SIGINT)
> {
> printf("mySignalHandler received SIGINT\n");
> printf("Doing a 1second sleep()\n");
> sleep(1);
> printf("1second sleep() finished\n");
> }
> else if (signo == SIGUSR2)
> {
> printf("mySignalHandler received SIGUSR2\n");
> printf("Doing a 1second sleep()\n");
> sleep(1); // XXX this sleep causes infinite loop within DCE, and a SIGSEGV in the end
> printf("1second sleep() finished\n");
> }
> else
> {
> printf("mySignalHandler received unknown signal\n");
> }
>
> }
>
> int main(int argc, char **argv)
> {
> sleep (1);
>
> printf("Testprogram for sighandler \n");
>
> if (signal(SIGINT, mySignalHandler) == SIG_ERR)
> {
> printf("signal(SIGINT, ...) failed \n");
> }
>
> if (signal(SIGUSR2, mySignalHandler) == SIG_ERR)
> {
> printf("signal(SIGUSR2, ...) failed \n");
> }
>
> while(1)
> {
> printf("main loop...\n");
> sleep(10);
> }
>
> return 1;
> }