On 7/13/07, Tassilo Horn <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a little problem with this fish script:
>
> --8<---------------cut here---------------start------------->8---
> #!/bin/fish
>
> set -l TITLE ""
>
> cpubar > ~/.cpubar.log &
>
> # the while has to run in a new subshell so that its output goes into
> # the pipe directly. Else the output would be blocked till the while
> # finishes.
> fish -c 'while true;
>   # notifications
>   set TITLE (status-show)
>   # dnamicLog stuff
>   set TITLE $TITLE "|" (tail -n 1 ~/.xmonad.log)
>   # battery
>   set TITLE $TITLE "|" (battery-status)
>   # cpubar
>   set TITLE $TITLE "|" (tail -n 1 ~/.cpubar.log)
>   # cpufreq
>   set -l cpufreq ""
>   set -l i 0
>   set -l lines (cat /proc/cpuinfo | grep "cpu MHz" | \
>                 sed -e "s/^.\+: //" | sed -e "s/\.[0123456789]*//")
>   for l in $lines
>     set cpufreq $cpufreq "CPU$i: $l"
>     set i (echo $i+1 | bc)
>   end
>   set TITLE $TITLE "|" $cpufreq
>   # date
>   set TITLE $TITLE "|" (date "+%a %F %T")
>
>   echo $TITLE
>
>   sleep 1
> end' | dzen2 -p -ta r -fn fixed -fg '#FFFFFF' -bg '#3F4C6B' -e \
>   'button3=exec:urxvt.sh;entertitle=uncollapse,unhide;leavetitle=collapse'
>
> killall cpubar
> --8<---------------cut here---------------end--------------->8---
>
> My problem is, that I want to kill all programs started with this script
> when the script is killed, too.
>
> Currently only cpubar is killed then, but dzen2 and the subshell running
> the while loop go on. Because there are many fish shells and sometimes
> more than one dzen2 running, I cannot kill them by name.
>
> So is there a way to get the pid of a prozess when or after I started
> it? Something like $_, but with the pid of the process would be great.
>
> Thanks,
> Tassilo
> --
>       "DRM manages rights in the same way a jail manages freedom"
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Fish-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fish-users
>

You can use the 'jobs' builtin. 'jobs -p %3' will give you the process
id:s of all processes in the job with job id 3. Unfortunatly, fish
does not currently have a simple way to get the job id of the last job
to run. You can grep the output og jobs or guess what it is knowing
that fish always choses the smallest non-occupied job id, starting at
1.

Adding a  $job_id varaible or a --last-job switch to the 'status'
builtin that tells you the job id of the last command to execute would
be a simple thing to add. Is it a good idea? Which one? I'm inclined
to like the status solution better, since I generally feel that a
variable should not be something magical.

Axel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to