summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-09-07 10:12:18 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-09-07 10:12:18 +0000
commitf061d9fc282f610624c3118430e78a5c9c7db32b (patch)
treee275512affa0c31e68175cd6feef3286c0d1cd01 /lib
parent5b9d7eec004b33f72a36e0a78061109d68dfbf53 (diff)
Use SOCK_CLOEXEC (instead of later using fcntl(F_SETFD)) when creating sockets
for talking to aucat/sndiod ok ratchov@
Diffstat (limited to 'lib')
-rw-r--r--lib/libsndio/aucat.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c
index 45fe710413e..4a10b773586 100644
--- a/lib/libsndio/aucat.c
+++ b/lib/libsndio/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.61 2013/12/20 08:51:28 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.62 2014/09/07 10:12:17 guenther Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -300,7 +300,8 @@ aucat_connect_tcp(struct aucat *hdl, char *host, unsigned int unit)
}
s = -1;
for (ai = ailist; ai != NULL; ai = ai->ai_next) {
- s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ s = socket(ai->ai_family, ai->ai_socktype | SOCK_CLOEXEC,
+ ai->ai_protocol);
if (s < 0) {
DPERROR("socket");
continue;
@@ -341,7 +342,7 @@ aucat_connect_un(struct aucat *hdl, unsigned int unit)
snprintf(ca.sun_path, sizeof(ca.sun_path),
"/tmp/aucat-%u/%s%u", uid, AUCAT_PATH, unit);
ca.sun_family = AF_UNIX;
- s = socket(AF_UNIX, SOCK_STREAM, 0);
+ s = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (s < 0)
return 0;
while (connect(s, (struct sockaddr *)&ca, len) < 0) {
@@ -455,10 +456,6 @@ _aucat_open(struct aucat *hdl, const char *str, unsigned int mode,
if (!aucat_connect_un(hdl, unit))
return 0;
}
- if (fcntl(hdl->fd, F_SETFD, FD_CLOEXEC) < 0) {
- DPERROR("FD_CLOEXEC");
- goto bad_connect;
- }
hdl->rstate = RSTATE_MSG;
hdl->rtodo = sizeof(struct amsg);
hdl->wstate = WSTATE_IDLE;