test FD_CLOEXEC
This commit is contained in:
parent
9b097994c2
commit
36823968f7
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: h_exec.c,v 1.1 2011/02/15 15:16:46 pooka Exp $ */
|
||||
/* $NetBSD: h_exec.c,v 1.2 2011/02/15 15:54:56 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
@ -56,10 +56,10 @@ main(int argc, char *argv[])
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "_didexec") == 0) {
|
||||
daemon(0, 0); /* detach-me-notnot ergo detach */
|
||||
s1 = atoi(argv[2]);
|
||||
s2 = atoi(argv[2]);
|
||||
slen = sizeof(sin);
|
||||
/* see below */
|
||||
accept(s1, (struct sockaddr *)&sin, &slen);
|
||||
accept(s2, (struct sockaddr *)&sin, &slen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,11 +92,18 @@ main(int argc, char *argv[])
|
||||
* "pause()", but conveniently gets rid of this helper
|
||||
* since we were called with RUMPCLIENT_RETRYCONN_DIE set
|
||||
*/
|
||||
accept(s1, (struct sockaddr *)&sin, &slen);
|
||||
accept(s2, (struct sockaddr *)&sin, &slen);
|
||||
}
|
||||
|
||||
if (argc == 3 && strcmp(argv[2], "cloexec1") == 0) {
|
||||
if (fcntl(s1, F_SETFD, FD_CLOEXEC) == -1) {
|
||||
fprintf(stderr, "repomies jumalauta %d!\n", errno);
|
||||
err(1, "cloexec failed");
|
||||
}
|
||||
}
|
||||
|
||||
/* omstart! */
|
||||
sprintf(buf, "%d", s1);
|
||||
sprintf(buf, "%d", s2);
|
||||
if (execl(argv[1], "h_ution", "_didexec", buf, NULL) == -1)
|
||||
err(1, "exec");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: t_exec.sh,v 1.1 2011/02/15 15:16:46 pooka Exp $
|
||||
# $NetBSD: t_exec.sh,v 1.2 2011/02/15 15:54:56 pooka Exp $
|
||||
#
|
||||
# Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
@ -77,9 +77,33 @@ exec_cleanup()
|
||||
rump.halt
|
||||
}
|
||||
|
||||
atf_test_case cloexec cleanup
|
||||
cloexec_head()
|
||||
{
|
||||
atf_set "descr" "check that FD_CLOEXEC works"
|
||||
}
|
||||
|
||||
cloexec_body()
|
||||
{
|
||||
|
||||
atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
|
||||
atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
|
||||
$(atf_get_srcdir)/h_exec $(atf_get_srcdir)/h_ution cloexec1
|
||||
atf_check -s exit:0 -o save:sstat.out rump.sockstat
|
||||
atf_check -s exit:0 -o inline:'2\n' sed -n '$=' sstat.out
|
||||
atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.2345' \
|
||||
sed -n 2p sstat.out
|
||||
}
|
||||
|
||||
cloexec_cleanup()
|
||||
{
|
||||
rump.halt
|
||||
}
|
||||
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case noexec
|
||||
atf_add_test_case exec
|
||||
atf_add_test_case cloexec
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user