wait
, waitpid
) of Perl do not return EINTR
when receiving a signal.This is a problem if you would want to wait for child processes until receiving a signal. Proc::Wait3 can be a solution, however the module may be hard to install as it is an XS module. It should also be noted that the module provides replacement for
wait
only; no workaround exists for waitpid
.So today I have scrubbed my head wondering if I could come up with a pure-perl solution, and, here it is. The Perl script below launches a worker process (that just sleeps), and waits for the process to complete, or until SIGTERM is being received.
use strict; use warnings; use Errno (); our $got_sigterm = 0; our $sighandler_should_die = 0; # fork a child process that does the task my $child_pid = fork; die "fork failed:$!" unless defined $child_pid; if ($child_pid == 0) { # in child process, do something... sleep 100; exit 0; } $SIG{TERM} = sub { $got_sigterm = 1; die "dying to exit from waitpid" if $sighandler_should_die; }; warn "master process:$$, child process:$child_pid"; # parent process, wait for child exit or SIGTERM while (! $got_sigterm) { if (my_waitpid($child_pid, 0) == $child_pid) { # exit the loop if child died warn "child process exitted"; $child_pid = -1; last; } } if ($child_pid != -1) { warn "got SIGTERM, stopping the child"; kill 'TERM', $child_pid; while (waitpid($child_pid, 0) != $child_pid) { } } sub my_waitpid { my @args = @_; local $@; my $ret = eval { local $sighandler_should_die = 1; die "exit from eval" if $got_sigterm; waitpid($args[0], $args[1]); }; if ($@) { $ret = -1; $! = Errno::EINTR; } return $ret; }
The trick is that
waitpid
is surrounded by a eval
within the my_waitpid
function, and the signal handler calls die
to exit the eval if the $sighandler_should_die
flag is being set. It is also essential to check the $got_sigterm
flag within the eval block after setting the $sighandler_should_die
flag, since otherwise there would be a race condition.By using these tricks it has now become possible to implement process managers in pure-perl!
Your work is very good and I appreciate you and hopping for some more informative posts. happy new year 2016 new year 2016
ReplyDeletebonne année 2016 imagenes de año nuevo 2016 imagenes de navidad 2016 feliz año nuevo 2016 Journée internationale des droits des femmes 2016
Hey Guys Must Check these :-
ReplyDeleteI can do that live show
I can do that live telecast
I can do that Show live streaming
muharram 2015 Images
muharram 2015 Hd Wallpapers
Happy muharram 2015 Quotes
Muharram 2015 Slogans
muharram 2015 Karbala sms
Muharram 2015 Quotes
10 muharram 2015 Talwar Matam Videos
Muharram 2015 Zanjeer Juloos Videos
muharram 2015 Poems
Hazrat Hussain Poetry 2015
muharram 2015 Qawwali Mp3
10 Muharram 2015 shayari
Muharram 2015 Status
Labbaik ya hussain mp3 Songs
Hazrat Hussain Hd Images
Happy Childrens Day 2015 Images
Mastizaade Box Office Collection
Mastizaade Funny Scenes
Mastizaade hd Videos
Mastizaade Hot Scenes
Mastizaade Movie Review
Mastizaade Romantic Scenes
Mastizaade Songs
Mastizaade trailer film
World Aids Day 2015 Quotes
World Aids Day 2015 Posters
World Aids Day 2015 Themes
World Aids Day 2015 Slogans
here you guy the best christmas and happy new year 2016 wishes check this out guys: -
ReplyDeleteChristmas Love Quotes
Christmas Love Messages
HAPPY NEW YEAR 2016 WISHES, GREETINGS , THOUGHTS AND STATUS FOR FB
CHRISTMAS LOVE MESSAGES, LOVE QUOTES, CUTE SAYINGS
Merry Christmas Wishes Greetings and Quotes
CHRISTMAS LOVE MESSAGES, LOVE QUOTES, CUTE SAYINGS
This blog is a great source of information which is very useful for me.
ReplyDeleteKolkata Knight Riders Team Squad Captain Name
KXIP New Players List
Royal Challengers Bangalore Jersey logo Images
coach factory outlet
ReplyDeletenike air max
timberland outlet
adidas yeezy
louis vuitton outlet
kate spade outlet
toms shoes outlet
celine
air jordan retro
true religion outlet
mont blanc pens
coach outlet store online
coach outlet
adidas originals
louis vuitton handbags
oakley vault
jordan 11s
louis vuitton outlet
michael kors outlet clearance
coach outlet
christian louboutin flats
oakley vault
tory burch flats
michael kors handbags
ray ban sunglasses
michael kors handbags
lebron james shoes 2015
christian louboutin shoes
louis vuitton
ray ban sunglasses
jordan shoes
polo ralph lauren
coach outlet store online
cheap jordans
adidas shoes
rolex submariner
asics shoes
toms outlet
coach outlet store online clearances
louis vuitton outlet
20168.2wengdongdong
fitflops
ReplyDeletelouis vuitton borse
oakley sunglasses cheap
birkin handbags
timberland outlet
discount oakley sunglasses
kd shoes
christian louboutin outlet
coach outlet online
cheap ugg boots
zhi20161216
Sifatnya sulit dibengkokkan, dilas dan dipotong. Kandungan 0,60 % – 1,50 % C Penggunaan :Supplier stainless steel
ReplyDeletePabrik sch 40
Supplier bondek
undangan pernikahan lucu
Pabrik Besi Cnp Profil Baja Gording
Pabrik Besi Siku Baja
دار السلام اهم شركة نقل عفش بالطائف وكذلك اهم شركة نقل عفش بمكة وجدة والمدينة المنورة تقوم الشركة بنقل العفش بحفر الباطن وتبوك وجازان وتقوم بنقل الاثاث بالقصيم
ReplyDeleteشركة نقل عفش بالطائف
شركة نقل عفش بالمدينة المنورة
شركة نقل عفش بجازان وابها
ReplyDeleteافضل شركة نقل عفش بجدة شركة الاطلال شركة نقل اثاث بجدة شركة متخصصة فى نقل اثاث بجدة على اعلى مستوى من نقل العفش بجدة
شركة نقل عفش بجدة
ReplyDeleteشركة نقل عفش
اهم شركات مكافحة حشرات بالخبر كذلك معرض اهم شركة مكافحة حشرات بالدمام والخبر والجبيل والخبر والاحساء والقطيف كذلك شركة رش حشرات بالدمام ومكافحة الحشرات بالخبر
شركة مكافحة حشرات بالدمام
شركة تنظيف خزانات بجدة الجوهرة من افضل شركات تنظيف الخزانات بجدة حيث ان تنظيف خزانات بجدة يحتاج الى مهارة فى كيفية غسيل وتنظيف الخزانات الكبيرة والصغيرة بجدة على ايدى متخصصين فى تنظيف الخزانات بجدة
شركة تنظيف خزانات بجدة
شركة كشف تسربات المياه بالدمام
شركة نقل عفش واثاث
Install full MICROSOFT office setup 365 with our support. Now setting up your account will be a cakewalk with us.
ReplyDeleteSetup and Install Office 2017/2018 365 on your Mac/PC with genuine OFFICE PRODUCT key.
Word, Excel, PowerPoint, Outlook, OneNote and OneDrive, on your PC,Publisher and Access.Everything you need for home, education and work.
We are providing independent support service if in case you face problem to activate or SETUP OFFICE product.
Regards - www.office.com/setup
Very nice post. I just stumbled up?n your weblog and wished to say that I have really enjoyed browsing ?our blog posts.
ReplyDeleteRegards - www.office.com/setup
ReplyDeleteThank you for joining us. his article is very helpful
Obat Herbal Paling Ampuh Untuk Mengobati Penyakit Hipotiroid
Manfaat Buah-Buahan Untuk Kesehatan
Obat Penyakit Sembelit Paling Ampuh
Obat Untuk Mengobati penyakit osteoarthritis
Bahaya Penyakit Muntaber dan cara mengatasinya
Obat Penyakit Jantung Bengkak
Cara Mengobati Penyakit Leukimia
Terima kasih artikelnya sangat membantu sekali mudah-mudahan artikel ini bermanfaat bagi semua.
ReplyDeleteCara Mengatasi Penyakit Kuning Yang Tak Kunjung Sembuh
Obat Herbal Untuk Penyakit Chikungunya
Obat Flu Dan Batuk Anak
Obat Herbal Untuk Sakit Perut Melilit
Obat Cacingan Super Ampuh
Obat Untuk Mengatasi Pudarnya Warna Kulit
Solusi Paling Tepat Untuk Penyakit Kanker Ovarium
Backlingan web bersama
ReplyDeletethe article is very petrifying, hopefully it can be useful and an important lesson.
Cara Mengatasi Penyebab Kekurangan Sel Darah Putih
Obat Epidural Hematoma
Cara Menghilangkan Benjolan Di Telinga
Beberapa Cara Untuk Mengobati Angin Duduk
Obat Trombosis Vena Dalam
Bahaya Nyeri Dada
I am happy to be here and this wonderful article. I have found here lots of interesting information for my knowledge I need. all the details you provide to us, it was very helpful and useful, thanks for sharing this post.
ReplyDeletekhasiat obat herbal
Obat penyakit kulit
cara mengilangkan benjolan
toko obat herbal sapnudin
sehat dan cantik alami
cara menghilangkan benjolan di selangkangan
I can only express a word of thanks. Because with the content on this blog I can add knowledge I, thank has been sharing this information. Do not forget to visit our website to share information and knowledge about health.|
ReplyDeleteCara mengobati Nyeri Belikat |
Cara Mengatasi Mata Kaki Bengkak |
obat herbal jantung koroner
I can only express a word of thanks. Because with the content on this blog I can add knowledge I, thank has been sharing this information. Do not forget to visit our website to share information and knowledge about health.|
ReplyDeleteCara Mengobati penyakit kanre pali |
Obat Filariasis Herbal |
Subhanallah, this is a very good article. Give me awareness. Because all this time I always had a lot of good intentions, but after I got the things I could share.
ReplyDeleteCara Menghilangkan Nyeri Dan Pegal Di Lutut
Tips Menyembuhkan Patah Tulang
Obat Kanker Payudara
I can only express a word of thanks. Because with the content on this blog I can add knowledge I, thank has been sharing this information. Do not forget to visit our website to share information and knowledge about health. |
ReplyDeletecara mengatasi radang panggul |
obat infeksi saluran kemih |
obat herbal infeksi usus |
sapnudin herbal |
obat pusing kliyengan |
nama obat diare pada anak
I can only express a word of thanks. Because with the content on this blog I can add knowledge I, thank has been sharing this information. Do not forget to visit our website to share information and knowledge about health. |
ReplyDeletecara mengatasi radang panggul |
obat infeksi saluran kemih |
obat herbal infeksi usus |
sapnudin herbal |
obat pusing kliyengan |
nama obat diare pada anak
Subhanallah, this is a very good article. Give me awareness. Because all this time I always had a lot of good intentions, but after I got the things I could share.
ReplyDeleteCara Menghilangkan Nyeri Dan Pegal Di Lutut Cara Mengatasi Emfisema Obat Hipertiroid Cara Mengatasi Tinnitus Obat Amandel Paling Ampuh
Given article is very helpful and very useful for my admin, and pardon me permission to share articles here hopefully helped :
ReplyDeleteObat kesrek tradisional
Cara menyembuhkan batuk rejan
Cara Menghilangkan Benjolan Di Kepala
Given article is very helpful and very useful for my admin, and pardon me permission to share articles here hopefully helped :
ReplyDeleteCara Menurunkan Trombosit Tinggi
Obat Nyeri Dada Ampuh
Cara Menyembuhkan Gudik Secara Alami
Cara Menyembuhkan Flek Paru Paru Secara Alami
Cara Menyembuhkan Penyakit Dompo
Cara menyembuhkan jantung koroner secara alami
Obat darah tinggi ampuh
Thank you very useful information admin, and pardon me permission to share articles here
ReplyDeletemay help :
Cara Menghilangkan Benjolan Di Belakang
Telinga
Cara mengobati pengapuran tulang lutut
Cara Menyembuhkan Gidu Secara Alami
Webroot.com/safe is a protection software solution that communicates with the cloud avoiding the hassle to manage the signature updates to deploy. for office setup visit office.com/setup
ReplyDeleteThank you bro, the information is very helpful
ReplyDeleteCara Mengobati Emfisema
Cara Mengobati Batu Empedu
Obat Eksim Paling Ampuh
Obat Gatal-Gatal Paling Mujarab
I hope the information we share is useful and can be the best solution to cure your illness ... amen
ReplyDeleteObat Batuk Berdarah
Obat Jerawat Batu
Cara Mengobati Liver
Obat Luka Diabetes
Obat Tipes Anak
This is a very great post and the way you express your all post details that is too good. Thanks for sharing with us this useful post :
ReplyDeletepengobatan cacar air
manfaat sari kurma
cara mengobati batu empedu
Nice to be visiting your blog again, it has been months for me. Well this article that i’ve been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share :
ReplyDeletecara mengobati kencing manis
cara mengobati gondok secara alami
What a way to express things. I have found comfort in reading this post and i am sure other users may feel the same, because this post carries a social message in it. Keep it up ! Regards:-
ReplyDeleteoffice.com/setup | norton.com/setup | mcafee.com/activate
Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative.
ReplyDeletemcafee.com/activate|
mcafee.com/activate|
mcafee.com/activate|
mcafee.com/activate|
norton.com/setup|
mcafee.com/activate
norton.com/setup to install setup product key, Learn how to download, install, and put into outfill Norton Setup concerning speaking the subject of your Windows and Mac device.
ReplyDeletehttp://norton-comnortonnorton.com
Get all Steps for installation and download, activate MS office setup. Enter your Office product key on www.office.com/setup.
ReplyDeletehttp://office-comofficecom.com
After visiting office.com/setup login to microsoft account to take steps sticking together of covenant of office setup, Any complexity in office.com/setup our accomplished will calm for office install.
ReplyDeletehttp://officecomoffiice.com