- If vim is executed in WSL in mintty, some garbage string caused
by "OSC Ps;? BEL/ST" will be shown in some situations. This patch
fixes the issue by removing "OSC Ps;? BEL/ST" from pseudo console
output.
- The code added by 8121b606e843c001d5ca5213d24099e04ebc62ca has a
bug which fails to remove multiple "CSI > Pm m" sequences. This
patch fixes the bug.
Add a 'src_pid' argument to dtable::dup_worker.
Use the latter in serialize/deserialize rather than repeating much of
what it does.
Don't duplicate the path_conv handle; it isn't needed.
When a process sends a file descriptor via an SCM_RIGHTS control
message, it creates a temporary copy of the fhandler associated with
that descriptor and sends a serialization of that copy. The
deserialization done by the receiver involves duplicating handles from
the copy, so the latter must stay alive until the deserialization is
done. But it must ultimately be closed in order to avoid a memory
leak.
We coordinate all this as follows:
- Introduce a new struct scm_pending_fd that contains information
about the temporary copy. For brevity, call such a struct a
"pending fd" in what follows.
- Maintain a list of pending fds in shared memory.
- Add several methods for manipulating the list to the af_unix_shmem_t
and fhandler_socket_unix classes.
- Also add a lock, 'scm_fd_lock', to control access to the list.
- When a serialized fhandler is received, the receiver sends an ack
back to the sender in an administrative packet with a control
message of a new (Cygwin-specific) type SCM_RIGHTS_ACK.
- grab_admin_pkt is called in various places to process these packets.
A complication here is that the process that calls grab_admin_pkt
might not be the process that originally sent the serialized
fhandler. (It could be a subprocess of the original process, for
example.) This is why we need to maintain the list of pending fds
in shared memory.
- Each fhandler_socket_unix keeps a count of the pending fds that it
has created but not yet processed; this count is in a new data
member 'my_npending_fd'.
- fhandler_socket_unix::close tries to process any remaining pending
fds before closing, but it gives up after a short timeout and
forcibly deletes them if necessary.
Make them member functions of the fhandler_socket_unix class.
Make them use void * instead of fh_ser * so that fhandler.h doesn't
need to know about fh_ser.
Since we are now only configuring once, in winsup, with
AC_CONFIG_AUX_DIR(..), the auxiliary files are taken from the top-level.
(Previously we had a random assorment of AC_CONFIG_AUX_DIR(..) and
AC_CONFIG_AUX_DIR(../..) in winsup subdirectories, so auxiliary files
would be taken from winsup or the top-level.)
There's doesn't seem to be much use in independently distributing these
subdirectories, so allowing them to be independently configured seems
pointless and overcomplicated.
The order in which the subdirectories are built is still a little odd,
as cygwin is linked with libcygserver, and cygserver is then linked with
cygwin. So, we build the cygwin directory first, which invokes a build
of libcygserver in the cygserver directory, and then build in the
cygserver directory to build the cygserver executable.
Drop AC_CONFIGURE_ARGS, since we don't need to recursively call
configure with the same arguments anymore.
Slightly refine when we build utils: Previously we didn't build any
utils if MinGW compiler use was avoided, now we just avoid building
those utils which require that compiler.
Greatly simplify how winsup_srcdir and target_builddir are set, since
we're only configuring from one directory. (These are still kept
absolute, since we don't adjust them where used for being used in a
subdirectory).
Remove configure.cygwin and put it's (greatly reduced) contents inline
in the one place it's used now.
Remove generated configure and aclocal.m4 in subdirectories.
This has a test of the path translation code used in various utilities
(mount, cygpath, strace).
MOUNT_BINARY is replaced with the absence of MOUNT_TEXT since 26e0b37e.
The issys member of mnt_t struct was removed in b677a99b.
> $ make check
[...]
> total tests: 63
> pass : 63 (100.0%)
> fail : 0 (0.0%)
'-fno-exceptions -fno-rtti' are already present in the compile command
COMPILE.cc set by Makefile.common, so we don't need to add them to
CXXFLAGS as well.
Invoke grep in text mode when looking for version strings inside the
cygwin DLL, so it outputs something more informative than:
Binary file ../cygwin/cygwin0.dll matches
The overflow check in mEMALIGn erroneously checks for INT_MAX,
albeit the input parameter is size_t. Fix this to check for
__SIZE_MAX__ instead. Also, it misses to check the req against
adding the alignment before calling mALLOc.
While at it, add out-of-bounds checks to pvALLOc, nano_memalign,
nano_valloc, and Cygwin's (unused) dlpvalloc.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
First cut. This is currently implemented only for disk files, and
many things still need to be fixed. But it works in limited testing
with the programs scm_rights_{recv,send} in
winsup/cygwin/socket_tests.
Define static helper functions serialize/deserialize in
fhandler_socket_unix.cc. These will be used to support sending file
descriptors via SCM_RIGHTS control messages.
The serialize function creates an 'fh_ser' structure that contains a
copy of the fhandler associated with the file descriptor, with all
allocated memory freed. The structure also contains the Windows pid
of the current process, which deserialize can use for duplicating
handles.
The deserialize function reconstructs an fhandler from an fh_ser
structure, with the handles duplicated into its own process.
For now, serialization and deserialization are fully implemented only
for disk files, and even in that case there are many FIXMEs that need
attention.
This allows duplication of handles from an fhandler created in a
different process. For now, this is implemented only for
fhandler_base and fhandler_disk_file.
Override this in each derived class to give the size of each fhandler
class so that the size can be computed dynamically from an
fhandler_base pointer.
Replace the 'WCHAR pipe_name_buf[48]' class member by 'PWCHAR
pipe_name_buf', and allocate space for the latter as needed.
Change the default constructor to accommodate this change, and add a
destructor that frees the allocated space.
Also change get_pipe_name and clone to accommodate this change.
By default, libltp tests will create temporary files in a subdirectory
of /tmp, which will (nowadays) be located relative to the test DLL (by
assuming that it is in /bin). This will evaluate to the directory
$target_builddir/winsup/tmp, which doesn't exist.
The location used for these temporary files can be explicitly controlled
by setting the TDIRECTORY env var. Arrange to set that env var to the
/cygdrive path of a tmp subdirectory of the build directory.
Unfortunately, libltp doesn't clean the temporary directory if
TDIRECTORY is set, and some tests assume they are started in a clean
directory, so we need to do that in tcl.
Set the PATH so that tests can pick up cygwin0.dll. Looks like this was
dropped by accident in 2e488e95 ("Don't rely on in-build tools"), so
restore it as it was prior to 9d89f634.
Drop MINGW_FE, which I can't find any trace of, and instead detect and
use MinGW compilers.
This requires adding AC_CANONICAL_TARGET, to set $target_cpu.
This is now required as cygwin_build is defined in terms of
target_builddir.
(Note that in other subdirectories, the autoconf variable
target_builddir is AC_SUBST-ed as a side-effect of using a macro from
winsup/acinclude.m4, which is perhaps less than ideal)