From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/1110 Path: news.gmane.org!not-for-mail From: Alex Efros Newsgroups: gmane.comp.sysutils.supervision.general Subject: sv t getty Date: Sat, 6 May 2006 21:55:26 +0300 Organization: asdfGroup Inc., http://powerman.asdfGroup.com/ Message-ID: <20060506185526.GB20720@home.power> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1146941732 19402 80.91.229.2 (6 May 2006 18:55:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 6 May 2006 18:55:32 +0000 (UTC) Original-X-From: supervision-return-1346-gcsg-supervision=m.gmane.org@list.skarnet.org Sat May 06 20:55:30 2006 Return-path: Envelope-to: gcsg-supervision@gmane.org Original-Received: from antah.skarnet.org ([212.85.147.14]) by ciao.gmane.org with smtp (Exim 4.43) id 1FcRw9-0007By-Bq for gcsg-supervision@gmane.org; Sat, 06 May 2006 20:55:29 +0200 Original-Received: (qmail 5173 invoked by uid 76); 6 May 2006 18:55:49 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Archive: Original-Received: (qmail 5167 invoked from network); 6 May 2006 18:55:49 -0000 Original-To: supervision@list.skarnet.org Mail-Followup-To: supervision@list.skarnet.org Content-Disposition: inline User-Agent: Mutt/1.5.11 Xref: news.gmane.org gmane.comp.sysutils.supervision.general:1110 Archived-At: Hi! As you know, bash can't be killed by TERM, it prefer HUP (or KILL). :) So, command: sv t getty1 will work if user not logged in on tty1 (so it will restart "*getty" process), and will not work if user is logged in on tty1 and running bash. To work around this issue (and make 'sv t' logout user in this tty and restart *getty) I make script /usr/local/bin/term-getty-service and symlink'ed to it from /var/service/*getty*/control/t . It's a little complex because I've to kill not only first bash executed by getty/login, but also all nested bash's (which can be executed for example by 'mc' or 'su'). --- /usr/local/bin/term-getty-service: --- #!/bin/bash bashs() { while [[ -n "$1" ]]; do pgrep -P $1 bash; bashs $(pgrep -P $1); shift; done; } bashs="$( bashs $(