Re: CVS commit: src

2012-12-17 Thread Jukka Ruohonen
On Mon, Dec 17, 2012 at 06:17:27PM +, Alan Barrett wrote:
> Log Message:
> Add shell implementations of basename and dirname to rc.subr.  They
> are supposed to mimic basename(1) and dirname(1), except that they
> are usable before /usr/bin is mounted.

This demands a question: is duplication better than restructuring /usr?

- Jukka.



Re: CVS commit: src/usr.sbin/envstat

2012-12-17 Thread Christos Zoulas
In article ,
Iain Hibbert   wrote:
>
>I didn't understand it, in any case.. can you explain why, in C, when
>exit() explicitly closes all open file descriptors and releases any memory
>etc (see a detailed list in exit(3) and _exit(3)), there might be a
>benefit in doing so formally before calling exit() ?

It is a slippery slope. Every program eventually exits, so it is up
to the author of the code to decide when it is late enough to avoid
doing cleanup. I think that everyone agrees that libraries should
have as few side effects as possible and free resources when they
are not needed. In the application case, this is not so clear. There
are claims of:

- loss of readabily
- slowing down exit
- the OS does not free resources until process destruction anyway

On the other side there is:

- memory usage/leak tools complain
- destruction path gets written/tested
- code gets reused/refactored in different places, and then
  the leaks become apparent
- sloppiness and laziness is not good programming practice
- buncombe :-)

And don't know, are there any others?

My experience has been that in the past, when I had to add resource
deallocation on code that did not do it before, it has been a complex,
time consuming, and error prone task. The main reason for that was
that the people who designed the code relied on the fact that there
would be no resource deallocation. This led to bad coding practices
throughout the code (why keep the original pointer around when we
are not planning to free it anyway; we can just move it around).
All these design decisions required heavy-handed structural changes
to the code to make it use resources properly.

So, I design for code reuse; I like to be able to use memory leak
detectors, and I've had to deal with programs that did not do so
well about resource allocation in the past (make, csh) so I appreciate
code that is designed with deallocation in mind.

christos



Re: CVS commit: src/tools

2012-12-17 Thread Matthias Scheler
On Sun, Dec 16, 2012 at 06:47:40AM +, Alan Barrett wrote:
> Module Name:  src
> Committed By: apb
> Date: Sun Dec 16 06:47:39 UTC 2012
> 
> Modified Files:
>   src/tools/libctf: Makefile
>   src/tools/libdwarf: Makefile
>   src/tools/libelf: Makefile
> 
> Log Message:
> If you are going to append things to CPPFLAGS and then transfer
> the result to HOST_CPPFLAGS later, then also include the value of
> HOST_CPPFLAGS in this process.  This should fix a problem in which the
> value of HOST_CPPFLAGS set by compat/defs.mk was lost during a build
> with MKDTRACE=yes.

That fixes the build for me.

Thanks a lot

-- 
Matthias Scheler  http://zhadum.org.uk/


Re: CVS commit: src/etc/rc.d

2012-12-17 Thread Nicolas Joly
On Fri, Dec 14, 2012 at 06:42:26PM +, Alan Barrett wrote:
> Module Name:  src
> Committed By: apb
> Date: Fri Dec 14 18:42:25 UTC 2012
> 
> Modified Files:
>   src/etc/rc.d: random_seed
> 
> Log Message:
> Avoid using programs from /usr/bin.  This should fix PR 47326.
> 
> - no need for "dirname", because "df -G" can take a file name directly.
> - replace use of "awk" with a shell while read loop.
> - replace use of "stat -s" with "ls -ldn".
> - no need for "tail" now that the use of "stat" has changed.
> 
> While here, also add some shell quotes and improve the grammar in a comment.

With this change, i do still see a bootstrap problem when
${random_file} doesn't exists ...

njoly@lynche [~]# ls -l /var/db/entropy-file
ls: /var/db/entropy-file: No such file or directory
root@lynche [~]# /etc/rc.d/random_seed stop
df: /var/db/entropy-file: No such file or directory

Actually, if the file does not exists it will fail to create one.

random_save()
{
oum=$(umask)
umask 077

rm -Pf "${random_file}"

if ! fs_safe "${random_file}"; then
return 1
fi

if rndctl -S "${random_file}"; then
echo "Saved entropy to disk."
fi
}

First, rm(1) is called before fs_safe() check which will always
fail. Even with the rm call commented or better moved just before
rndctl, the fs_safe call will fail in df(1) if file does not already
exists. Chicken or Egg ...

-- 
Nicolas Joly

Biology IT Center
Institut Pasteur, Paris.


Re: CVS commit: src/usr.sbin/envstat

2012-12-17 Thread Iain Hibbert
On Sun, 16 Dec 2012, David Holland wrote:

> On Fri, Dec 14, 2012 at 06:18:57PM +0100, Marc Balmer wrote:
>  > proper resource management is a good thing - if the code continues
>  > to run. In this case, where the program exits, there no benefit
>  > from freeing up memory etc.
>
> Buncombe.

is that a technical argument?

I didn't understand it, in any case.. can you explain why, in C, when
exit() explicitly closes all open file descriptors and releases any memory
etc (see a detailed list in exit(3) and _exit(3)), there might be a
benefit in doing so formally before calling exit() ?

regards,
iain