Re: one process, different PID
- From: "Joachim Schmitz" <nospam.jojo@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 26 Jun 2008 18:48:12 +0200
within the list of parameter declarations in a function prototype (not part
of a function
definition), the identifier has function prototype scope, which terminates
at the end of the
function declarator. If an identifier designates two different entities in
the same name
space, the scopes might overlap. If so, the scope of one entity (the inner
scope) will be a
strict subset of the scope of the other entity (the outer scope). Within the
inner scope, the
identifier designates the entity declared in the inner scope; the entity
declared in the outer
scope is hidden (and not visible) within the inner scope.
5 Unless explicitly stated otherwise, where this International Standard uses
the term
??identifier?? to refer to some entity (as opposed to the syntactic
construct), it refers to the
entity in the relevant name space whose declaration is visible at the point
the identifier
occurs.
6 Two identifiers have the same scope if and only if their scopes terminate
at the same
point.
7 Structure, union, and enumeration tags have scope that begins just after
the appearance of
the tag in a type specifier that declares the tag. Each enumeration constant
has scope that
begins just after the appearance of its defining enumerator in an enumerator
list. Any
other identifier has scope that begins just after the completion of its
declarator.
Joachim Schmitz wrote:
NBaH wrote:Another possuble fix would be to use
On 26 juin, 15:56, NBaH <n_b_a_...@xxxxxxxxxx> wrote:Ah, yes, sorry, I noticed that & and was about to tell you about it
On 26 juin, 15:37, "Joachim Schmitz"
<nospam.j...@xxxxxxxxxxxxxxxxxx> wrote:
NBaH wrote:
Hello world !
As I intend to suspend a daemon I wrote
$~ cat /usr/sbin/diva
#!/bin/bash
# DIVA
## stands for: Disconnects Idle Virtual_terminals Automatically
export LC_TIME=C
pidof -x $0 >/var/run/$(basename $0).pid
Why not simply
echo $$ >/var/run/$(basename $0).pid
while :
do
idle_tty2stop=$(who -u | awk -F" " '$6 ~/5$/ { print $7 }')
tty2watch=$(who -u | awk -F" " '$6 ~/5$/ { print $6 }' | cut -d:
- f2)
for i in $tty2watch; do
[ $tty2watch -gt "4" ] && tput reset
kill -s TERM $idle_tty2stop > /dev/null 2>&1
done
sleep 60
done &
$~
I adapted the /etc/init.d/skeleton.
Daemon works fine at boot, and disconnects idle TTYs after 5mn.
But, as I want to stop it by typing `/etc/init.d/diva stop`, it
doesn't stop, because the value in /var/run/diva.pid is not
correct : $~ pidof -x /usr/sbin/diva
$~ 3330
$~ cat /var/run/diva.pid
$~ 3328
Does anybody have a clue to solve this trouble? Thanks
Bye, Jojo
It's the same... I first tried `echo $$` which provides the
behaviour I described, so I tried `pidof` with the same effect, and
I let the script in this state.
OK! I found the solution: it's the "done &" stuff at the end of the /
usr/sbin/diva's script. I removed the "&", placed "--background" in
the do_start function of /etc/init.d/skeleton-like script.
Now, pidof -x /usr/sbin/diva and cat /var/run/diva.pid are the same.
but got distratcted...
echo $! >/var/run/$(basename $0).pid
after (!) the "done &", as that's the time at which the PID of that
background process is know
Bye, Jojo
.
- Follow-Ups:
- Re: one process, different PID
- From: NBaH
- Re: one process, different PID
- References:
- one process, different PID
- From: NBaH
- Re: one process, different PID
- From: Joachim Schmitz
- Re: one process, different PID
- From: NBaH
- Re: one process, different PID
- From: NBaH
- Re: one process, different PID
- From: Joachim Schmitz
- one process, different PID
- Prev by Date: Re: one process, different PID
- Next by Date: Re: best tool for creating a marquee animation on the Linux command line
- Previous by thread: Re: one process, different PID
- Next by thread: Re: one process, different PID
- Index(es):
Relevant Pages
|