diff options
author | jdike <jdike> | 2003-08-07 18:57:05 +0000 |
---|---|---|
committer | jdike <jdike> | 2003-08-07 18:57:05 +0000 |
commit | d207791568d377bd2cdaee26dc0e19a405976050 (patch) | |
tree | b3b41f117f3d032fe721f3477bd6f7416059d46d | |
parent | 09ef23fe908d22571c9869a003d947f16eb60511 (diff) | |
download | uml-history-d207791568d377bd2cdaee26dc0e19a405976050.tar.gz |
Unix sockets now have the option of being FD_CLOEXEC, and all callers of
create_unix_socket take advantage of this.
-rw-r--r-- | arch/um/drivers/xterm.c | 2 | ||||
-rw-r--r-- | arch/um/include/os.h | 2 | ||||
-rw-r--r-- | arch/um/os-Linux/file.c | 6 |
3 files changed, 7 insertions, 3 deletions
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c index 59c4ba8..ad26b27 100644 --- a/arch/um/drivers/xterm.c +++ b/arch/um/drivers/xterm.c @@ -108,7 +108,7 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out) } close(fd); - fd = create_unix_socket(file, sizeof(file)); + fd = create_unix_socket(file, sizeof(file), 1); if(fd < 0){ printk("xterm_open : create_unix_socket failed, errno = %d\n", -fd); diff --git a/arch/um/include/os.h b/arch/um/include/os.h index e3f9dcb..e6d99c5 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -103,7 +103,7 @@ extern int os_accept_connection(int fd); extern int os_shutdown_socket(int fd, int r, int w); extern void os_close_file(int fd); extern int os_rcv_fd(int fd, int *helper_pid_out); -extern int create_unix_socket(char *file, int len); +extern int create_unix_socket(char *file, int len, int close_on_exec); extern int os_connect_socket(char *name); extern int os_file_type(char *file); extern int os_file_mode(char *file, struct openflags *mode_out); diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index 7919020..93e9f93 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c @@ -314,7 +314,7 @@ int os_rcv_fd(int fd, int *helper_pid_out) return(new); } -int create_unix_socket(char *file, int len) +int create_unix_socket(char *file, int len, int close_on_exec) { struct sockaddr_un addr; int sock, err; @@ -326,6 +326,10 @@ int create_unix_socket(char *file, int len) return(-errno); } + if(close_on_exec && fcntl(sock, F_SETFD, 1) < 0) + printk("create_unix_socket : Setting FD_CLOEXEC failed, " + "errno = %d", errno); + addr.sun_family = AF_UNIX; /* XXX Be more careful about overflow */ |