* include/posix.h (_Jv_platform_close_on_exec): New function.
Include fcntl.h.
* include/win32.h (_Jv_platform_close_on_exec): New function.
* java/net/natPlainSocketImpl.cc (create): Set close-on-exec
flag.
(accept): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (create): Set
close-on-exec flag.
* java/io/natFileDescriptorPosix.cc (open): Set close-on-exec
flag.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50536
138bc75d-0d04-0410-961f-
82ee72b054a4
+2002-03-10 Tom Tromey <tromey@redhat.com>
+
+ * java/lang/Win32Process.java: Added comment.
+ * include/posix.h (_Jv_platform_close_on_exec): New function.
+ Include fcntl.h.
+ * include/win32.h (_Jv_platform_close_on_exec): New function.
+ * java/net/natPlainSocketImpl.cc (create): Set close-on-exec
+ flag.
+ (accept): Likewise.
+ * java/net/natPlainDatagramSocketImpl.cc (create): Set
+ close-on-exec flag.
+ * java/io/natFileDescriptorPosix.cc (open): Set close-on-exec
+ flag.
+
2002-03-09 Tom Tromey <tromey@redhat.com>
* verify.cc (state::NO_STACK): New constant.
#include <unistd.h>
#endif
+#include <fcntl.h>
+
#include <gcj/cni.h>
extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *);
extern jlong _Jv_platform_gettimeofday ();
extern void _Jv_platform_initialize (void);
-
-
-
-
+inline void
+_Jv_platform_close_on_exec (jint fd)
+{
+ // Ignore errors.
+ fcntl (fd, F_SETFD, FD_CLOEXEC);
+}
extern void _Jv_platform_initialize (void);
extern jlong _Jv_platform_gettimeofday ();
+void _Jv_platform_close_on_exec (jint)
+{
+ // Ignore.
+}
+
#endif /* __JV_WIN32_H__ */
#include <string.h>
#include <sys/stat.h>
#include <sys/param.h>
-#include <fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
#define BSD_COMP /* Get FIONREAD on Solaris2. */
sprintf (msg, "%s (%s)", buf, strerror (errno));
throw new FileNotFoundException (JvNewStringLatin1 (msg));
}
+
+ _Jv_platform_close_on_exec (fd);
+
return fd;
}
// This is entirely internal to our implementation.
+// NOTE: when this is implemented, we'll need to add
+// HANDLE_FLAG_INHERIT in FileDescriptor and other places, to make
+// sure that file descriptors aren't inherited by the child process.
+// See _Jv_platform_close_on_exec.
+
// This file is copied to `ConcreteProcess.java' before compilation.
// Hence the class name apparently does not match the file name.
final class ConcreteProcess extends Process
-/* Copyright (C) 1999, 2000 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
This file is part of libgcj.
char* strerr = strerror (errno);
throw new java::net::SocketException (JvNewStringUTF (strerr));
}
+
+ _Jv_platform_close_on_exec (sock);
+
fnum = sock;
fd = new java::io::FileDescriptor (sock);
}
char* strerr = strerror (errno);
throw new java::io::IOException (JvNewStringUTF (strerr));
}
+
+ _Jv_platform_close_on_exec (sock);
+
fnum = sock;
fd = new java::io::FileDescriptor (sock);
}
new_socket = _Jv_accept (fnum, (sockaddr*) &u, &addrlen);
if (new_socket < 0)
goto error;
+
+ _Jv_platform_close_on_exec (new_socket);
+
jbyteArray raddr;
jint rport;
if (u.address.sin_family == AF_INET)