{"id":2889,"date":"2019-12-25T05:03:18","date_gmt":"2019-12-25T05:03:18","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=2889"},"modified":"2019-12-25T05:08:50","modified_gmt":"2019-12-25T05:08:50","slug":"linux-send-usr1-signal-to-pid","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/linux-send-usr1-signal-to-pid\/","title":{"rendered":"Linux, Send USR1 signal to pid"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In Linux you can send signals to a process id to trigger actions for the program.  Useful scenario for this is to renew an IP address on a device that uses udhcpc.  You should be able to change udhcpc for other programs, you&#8217;ll just need to read the help for that specific program.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the udhcpc help it says <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Signals:\n         USR1    Renew lease\n         USR2    Release lease<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">But how do we send those signals to udhcpc?  Answer, use the kill command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">kill: kill [-s sigspec | -n signum | -sigspec] pid | jobspec \u2026 or kill -l [sigspec]\n     Send a signal to a job.\n\n<code>Send the processes identified by PID or JOBSPEC the signal named by SIGSPEC or SIGNUM.  If neither SIGSPEC nor SIGNUM is present, then SIGTERM is assumed. <\/code>\n\n<code>Options:   <\/code>\n<code>-s sig    SIG is a signal name   <\/code>\n<code>-n sig    SIG is a signal number   <\/code>\n<code>-l        list the signal names; if arguments follow `-l' they are             <\/code>\n          <code>assumed to be signal numbers for which names should be listed   <\/code>\n<code>-L        synonym for -l <\/code>\n\n<code>Kill is a shell builtin for two reasons: it allows job IDs to be used<\/code> <code>instead of process IDs, and allows processes to be killed if the limit on processes that you can create is reached<\/code>.\n<code>Exit Status:<\/code>\n<code>Returns success unless an invalid option is given or an error occurs. <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We see from above that we can pass a signal name in using the -s option.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So to send USR1 signal to udhcp we do the following<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">kill -s USR1 pid_of_udhcpc<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace pid_of_udhcpc with the actual pid or use the following command to find the pid<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">kill -s USR1 $(pgrep udhcpc)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">&#8220;pgrep udhcpc&#8221; prints the pid of the searched for process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Helpful links<br><a href=\"https:\/\/www.thegeekstuff.com\/2011\/02\/send-signal-to-process\/\">https:\/\/www.thegeekstuff.com\/2011\/02\/send-signal-to-process\/<\/a><br><a href=\"https:\/\/www.linux.org\/threads\/kill-signals-and-commands-revised.11625\/\">https:\/\/www.linux.org\/threads\/kill-signals-and-commands-revised.11625\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux you can send signals to a process id to trigger actions for the program. Useful scenario for this is to renew an IP address on a device that uses udhcpc. You should be able to change udhcpc for &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/linux-send-usr1-signal-to-pid\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[744,838,7,837,794,834,835,836],"class_list":["post-2889","post","type-post","status-publish","format-standard","hentry","category-linux","tag-dhcp","tag-kill","tag-linux-2","tag-pid","tag-signal","tag-udhcpc","tag-usr1","tag-usr2"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=2889"}],"version-history":[{"count":8,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2889\/revisions"}],"predecessor-version":[{"id":2897,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2889\/revisions\/2897"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=2889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=2889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=2889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}