1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) International Business Machines Corp., 2002 4 * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com> 5 */ 6 7 /*\ 8 * [Description] 9 * 10 * Verify that slave pseudo-terminal fails reading/writing if master has been 11 * closed. 12 */ 13 14 #define _GNU_SOURCE 15 16 #include "common.h" 17 run(void)18static void run(void) 19 { 20 int slavefd; 21 int masterfd; 22 char buf; 23 24 masterfd = open_master(); 25 slavefd = open_slave(masterfd); 26 27 tst_res(TINFO, "Closing master communication"); 28 SAFE_CLOSE(masterfd); 29 30 TST_EXP_EQ_LI(read(slavefd, &buf, 1), 0); 31 TST_EXP_FAIL(write(slavefd, &buf, 1), EIO); 32 33 SAFE_CLOSE(slavefd); 34 } 35 36 static struct tst_test test = { 37 .test_all = run, 38 }; 39