From patchwork Thu Nov 4 12:19:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Gongyi X-Patchwork-Id: 1550868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HlN2j4K8nz9s0r for ; Thu, 4 Nov 2021 23:18:21 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0425E3C72F1 for ; Thu, 4 Nov 2021 13:18:17 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 623B93C6A5E for ; Thu, 4 Nov 2021 13:18:14 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 04B5D140164A for ; Thu, 4 Nov 2021 13:18:12 +0100 (CET) Received: from dggeml753-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HlN2F0Htkz90HZ for ; Thu, 4 Nov 2021 20:17:57 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.63) by dggeml753-chm.china.huawei.com (10.1.199.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Thu, 4 Nov 2021 20:18:06 +0800 From: Zhao Gongyi To: Date: Thu, 4 Nov 2021 20:19:41 +0800 Message-ID: <20211104121941.32957-1-zhaogongyi@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.63] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggeml753-chm.china.huawei.com (10.1.199.152) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH] syscalls/fanotify: Kill the child process before exit X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Before the main process exit abnormally, we need to kill the child process. Signed-off-by: Zhao Gongyi --- .../kernel/syscalls/fanotify/fanotify07.c | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/testcases/kernel/syscalls/fanotify/fanotify07.c b/testcases/kernel/syscalls/fanotify/fanotify07.c index cc56d9019..0a0b4f1e4 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify07.c +++ b/testcases/kernel/syscalls/fanotify/fanotify07.c @@ -108,6 +108,39 @@ static int setup_instance(void) return fd; } +static int setup_another_instance(void) +{ + int rval; + int fd = fanotify_init(FAN_CLASS_CONTENT, O_RDONLY); + + if (fd == -1) { + stop_children(); + tst_brk(TBROK | TERRNO, "fanotify_init() failed"); + } + + if (fd < -1) { + stop_children(); + tst_brk(TBROK | TERRNO, + "invalid fanotify_init() return %d", fd); + } + + rval = fanotify_mark(fd, + FAN_MARK_ADD, FAN_ACCESS_PERM, AT_FDCWD, fname); + + if (rval == -1) { + stop_children(); + tst_brk(TBROK | TERRNO, "fanotify_mark() failed"); + } + + if (rval < -1) { + stop_children(); + tst_brk(TBROK | TERRNO, + "invalid fanotify_mark() return %d", rval); + } + + return fd; +} + static void loose_fanotify_events(void) { int not_responded = 0; @@ -160,7 +193,7 @@ static void test_fanotify(void) * Create and destroy another instance. This may hang if * unanswered fanotify events block notification subsystem. */ - newfd = setup_instance(); + newfd = setup_another_instance(); SAFE_CLOSE(newfd);