bug#20111: nice.1, renice.1 and nice.info : claims non-root user cannot decrease niceness

2015-03-15 Thread Stéphane Aulery
Hello,

I had you followed a bug reported by a Ubuntu user [1] about nice value 
change:

   According to man nice and info coreutils nice, it is
   not possible for a non-root user to decrease the niceness
   of a process (even if they were the ones that increased the
   niceness). However this not the case in Ubuntu 9.04, as
   evidenced by the fact that the attached script stopfirefox
   can reduce the niceness back to 0 when firefox is unminimized.
   The manpage and infopage should be modified in light of this,
   and should also say where this was configured.

   According to
   http://en.wikipedia.org/wiki/Nice_%28Unix%29#cite_note-0 This
   can be configured in /etc/security/limits.conf, however this
   does not seem to have any uncommented lines, so presumably
   Ubuntu configured this somewhere else.

   ProblemType: Bug
   Architecture: amd64

   DistroRelease: Ubuntu 9.04
   NonfreeKernelModules: fglrx
   PackageArchitecture: all
   ProcEnviron:
   SHELL=/bin/bash
   PATH=(custom, user)
   LANG=en_AU.UTF-8
   Uname: Linux 2.6.28-14-generic x86_64

I think that add a reference to talk about /etc/security/limits.conf is
a good idea.

[1] https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/468518

Regards,

-- 
Stéphane Aulery
#!/bin/sh
#
# A simple shell script to stop Firefox using CPU and paging in RAM
#
# John C. McCabe-Dansted, 2009
# Permission is given to use this file under any version of the GPL or LGPL.
#
# Bugs: 1) Only checks if one Firefox window is minimised, others may be
# unminimized, but this will still leave Firefox halted and unresponsive
# until the window this is actually checking is unminimized
#
#   2) Do not minimize Firefox while downloading, or the download will
# time out.
#
#   3) This script itself will use a tiny bit of CPU and RAM while polling
# xwininfo to determine whether Firefox is minimised. You may want to tune
# DELAY. Note that Firefox will be unresponsive for up to DELAY seconds
# after being unminimised.

DELAY=1 # in seconds

main () {
WinID=$1
PID=$3

echo WinID: $WinID
echo PID:   $PID

set_running () {
if [ $active = yes ]
then
kill -s CONT $PID
else
kill -s STOP $PID
fi
}

set_nice () {
if [ $active = yes ]
then
renice +0 $PID
else
renice +19 $PID
fi
}

kill -s CONT $PID
running=yes
while true
do
if xwininfo -id $WinID | grep 'Map State: IsUnMapped'  /dev/null
then 
#Minimized
active=no
else 
active=yes
fi
if [ $active = no ]
then
sleep 0.1
kill -s STOP $PID
sleep 0.5
if ! kill -s CONT $PID
then
exit
fi
else
sleep $DELAY

fi


#echo $active
if [ ! $running = $active ]
then
set_nice
running=$active
fi
done
}

main `wmctrl -l -p | grep  - Mozilla Firefox$`


bug#20094: cp --dry-run

2015-03-15 Thread Bernhard Voelker
On 03/13/2015 05:58 PM, 積丹尼 Dan Jacobson wrote:
 I'm pretty much sure I can successfully cp/mv entire
 complicated tree A onto entire complicated tree B, but it would be great
 to know before I get started if deep inside B there is something that
 will cause some tiny part of the whole operation to fail.

I don't think a dry-run could ever predict a failure in a reliable way.
As an abstract example let's assume that such a clever copy program would
calculate the needed space in the destination upfront, and would be able
to issue an error like the command would fail because of low disk space.
But in the case the space is sufficient (at the time of calculation), it
could never predict external influences, e.g. another program filling the
disk at the same time.  The same applies to permission issues, etc.: even
if the determination of an issue is accurate, it would still be racy in
every case.

Have a nice day,
Berny





bug#20114: tr does not support multibyte characters in the first argument

2015-03-15 Thread Bruno Haible
POSIX [1] specifies that the recognition of characters in 'tr' depends on
the environment variables LANG, etc.

But trying to replace a multibyte character by another character does not
work:

$ echo $LANG
de_DE.UTF-8
$ enspace=`printf '\u2002'`
$ echo -n X${enspace}Y | tr ${enspace} ' ' | od -t x1
000 58 20 20 20 59
005

Expected output would be:
$ echo -n X${enspace}Y | tr ${enspace} ' ' | od -t x1
000 58 20 59
003

With 'sed' it works:

$ echo -n X${enspace}Y | sed -e s/${enspace}/ /g | od -t x1
000 58 20 59
003

Bruno

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tr.html