From: Alex Efros <powerman@powerman.asdfGroup.com>
Subject: sv t getty
Date: Sat, 6 May 2006 21:55:26 +0300 [thread overview]
Message-ID: <20060506185526.GB20720@home.power> (raw)
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 $(<supervise/pid) )"
[[ -n "$bashs" ]] && kill -HUP $bashs
exit 1 # runsv must send TERM to getty if user don't logged in this console
---
The question is: is there exists more simple way for this task?
BTW, I suppose there a race condition in my script - if user spawn new
nested bash while this script will work between 'pgrep' and 'kill'.
--
WBR, Alex.
reply other threads:[~2006-05-06 18:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060506185526.GB20720@home.power \
--to=powerman@powerman.asdfgroup.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).