Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

HEADS-UP - sh fcntl() 3rd arg usage changed



The (very) recent change to sh includes an (intended to just
keep compilers quiet) alteration to the way that the 3rd
arg to fcntl() is passed when it is an int.

Previously it just did: fcntl(fd, CMD, N)
where N is some integer (or integer expression).

However, I noticed that the kernel treats the arg as a void *
and often seems to fetch that int as a long rather than int
(though it has complex endian dependany structs to allow it
to fetch the right bits).

Particularly if you have a big endian (and perhaps 32 bit)
system, and you update to a system from HEAD newer than about
right now, please check if this is working.

An easy way is to create a 2 line script

	#!/bin/sh
	fdflags -v

and make it executable.   For the purposes of this message
I will call it /tmp/T but you can call it anything you like,
just replace /tmp/T by the name of the file you used.

Then, while running /bin/sh do

	/tmp/T 5>/dev/null
	exec 5>/dev/null
	/tmp/T

The output from the first call to /tmp/T should show fd 5
as open, the output from the second should not.

You can also check that the fdflags command works properly:
(still in /bin/sh)

	exec 6>/dev/null
	fdflags -v
	fdflags -s +append,-cloexec 6
	fdflags -v

and verify that in the output from the 1st fdflags, the
line for fd 6 says +cloexec and -append and in the output
from the second fdflags -v for fd 6 it now sayw -cloexec
and +append.

If all that is correct, everything should be fine.  If not,
please let me know what happens.

kre


Home | Main Index | Thread Index | Old Index