generic: test record locks across execve in multithread process
authorXiong Zhou <xzhou@redhat.com>
Mon, 23 Apr 2018 02:42:48 +0000 (10:42 +0800)
committerEryu Guan <guaneryu@gmail.com>
Fri, 27 Apr 2018 11:06:48 +0000 (19:06 +0800)
commit7bc26faa6b52a2035f659c90a2833a453a18bace
tree381c5998eb4095743c85e0af0805d52be594f2b3
parenta6f6336df750d37b06f572564cbe767cc4837bb5
generic: test record locks across execve in multithread process

POSIX requires that record locks are preserved across an execve(2).
But currently the locks are released if process is multithreaded at
the time that execve is called.

As Jeff Layton wrote in his patch:
"
In that case, we'll end up unsharing the files_struct but the locks
will still have their fl_owner set to the address of the old one.
Eventually, when the other threads die and the last reference to the
old files_struct is put, any POSIX locks get torn down since it
looks like a close occurred on them.

The result is that all of your open files will be intact with none
of the locks you held before execve.
"

Add a new regression test for this particular case.

[Eryu: rewrite commit log and test description]

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
.gitignore
src/Makefile
src/t_locks_execve.c [new file with mode: 0644]
tests/generic/484 [new file with mode: 0755]
tests/generic/484.out [new file with mode: 0644]
tests/generic/group