>
> Andrew> Is this behaviour deliberate, or a bug? The chown binary
> Andrew> from gnu coreutils does not do this.
>
> You don't say what platform you are running on, but "man 2 chown" on
> my RH8 box says (in part):
>
> When the owner or group of an executable file are changed by a
non-
> super-user, the S_ISUID and S_ISGID mode bits are cleared. POSIX
does
> not specify whether this also should happen when root does the
chown;
> the Linux behaviour depends on the kernel version. In case of a
non-
> group-executable file (with clear S_IXGRP bit) the S_ISGID bit
indi-
> cates mandatory locking, and is not cleared by a chown.
>
> so Ruby is just doing what the system call does.
>
Thanks Daniel. This not only answers my question, but brings to my notice
the mysterious lack of man2 manual pages on my system ;)

I guess /bin/chown must explicitly save the permissions then reset them
after the call to chown()

Thanks

Andrew Walrond