in reply to Signaling in forked threads

forks is not threading! And despite it's continued billing as a drop in replacement for threads, it behaves and performs completely differently in every way that is critical: signals, memory, IO, scheduling, semaphoring, locking etc. And refering to forking as "threading" just confuses everyone.

If you can't or won't install a thread-capable build of Perl, then you will have to use fork for your multi-processing needs. So save yourself, and those that follow you, a lot of grief, and learn to use fork, or one of the many good wrappers like: Parallel:ForkManager now. Rather than pretending to use threads via forks which gives none of the benefits of the former, and compounds most of the downsides of both.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^2: Signaling in threads
by ajeet@perl (Acolyte) on Apr 07, 2010 at 11:22 UTC
    CODE 1
    #!/usr/bin/perl print "Hello Monks";

    running the above code and grepping the process results in one process

    CODE 2

    #!/usr/bin/perl use forks; print "Hello Monks";

    running the above code and grepping the process results in two process.

    You all are right, it is actually different process not threads. Now in the code 2, smaller process id is of main program and other process id is one when i write "use fork". Now i want to register a handle for 'SIGUSR2' for the process created by "use forks;"

      Sorry, I cannot help you. The forks module does not run on my system.

      My point was that by mentioning "threads" in the title of your question, you are attracting the wrong people to read it.

      If you need help with the forks module, you should mention that module in your title. And not use the term "threading" when you are forking.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.