<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/24926">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vty: add "shutdown"<br><br>Kill programs with SIGTERM with the new vty command, as it would happen<br>with "systemctl stop".<br><br>I've considered running the select shutdown logic too in order to ensure<br>that pending OSMO_FD_WRITE requests are serviced. But as noted in<br>review, it's better to ensure that the regular SIGTERM code path works<br>as expected and call that instead of introducing an alternative code<br>path.<br><br>Closes: OS#4609<br>Change-Id: I3596a35b0f4a24e49484ec3f24a98e4d4f583e1e<br>---<br>M src/vty/command.c<br>1 file changed, 16 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/vty/command.c b/src/vty/command.c</span><br><span>index 5001d06..3112fee 100644</span><br><span>--- a/src/vty/command.c</span><br><span>+++ b/src/vty/command.c</span><br><span>@@ -38,13 +38,16 @@</span><br><span> #include <ctype.h></span><br><span> #include <time.h></span><br><span> #include <limits.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <signal.h></span><br><span> #include <sys/time.h></span><br><span> #include <sys/stat.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <sys/types.h></span><br><span> </span><br><span> #include <osmocom/vty/vector.h></span><br><span> #include <osmocom/vty/vty.h></span><br><span> #include <osmocom/vty/command.h></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/logging.h></span><br><span> #include <osmocom/core/talloc.h></span><br><span> #include <osmocom/core/timer.h></span><br><span> #include <osmocom/core/utils.h></span><br><span>@@ -3022,6 +3025,18 @@</span><br><span>        return CMD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(shutdown,</span><br><span style="color: hsl(120, 100%, 40%);">+      shutdown_cmd, "shutdown", "Request a shutdown of the program\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  LOGP(DLGLOBAL, LOGL_INFO, "Shutdown requested from telnet\n");</span><br><span style="color: hsl(120, 100%, 40%);">+      vty_out(vty, "%s is shutting down. Bye!%s", host.app_info->name, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Same exit path as if it was killed by the service manager */</span><br><span style="color: hsl(120, 100%, 40%);">+       kill(getpid(), SIGTERM);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Show version. */</span><br><span> DEFUN(show_version,</span><br><span>       show_version_cmd, "show version", SHOW_STR "Displays program version\n")</span><br><span>@@ -4394,6 +4409,7 @@</span><br><span>                 install_lib_element(ENABLE_NODE, &config_disable_cmd);</span><br><span>           install_lib_element(ENABLE_NODE, &config_terminal_cmd);</span><br><span>          install_lib_element(ENABLE_NODE, &copy_runningconfig_startupconfig_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+          install_lib_element(ENABLE_NODE, &shutdown_cmd);</span><br><span>         }</span><br><span>    install_lib_element(ENABLE_NODE, &show_startup_config_cmd);</span><br><span>      install_lib_element(ENABLE_NODE, &show_version_cmd);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/24926">change 24926</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/24926"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I3596a35b0f4a24e49484ec3f24a98e4d4f583e1e </div>
<div style="display:none"> Gerrit-Change-Number: 24926 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: osmith <osmith@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>