xref: /third_party/ltp/testcases/kernel/syscalls/pipe2/pipe2_02_child.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/ltp/testcases/kernel/syscalls/pipe2/
1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (c) 2020 FUJITSU LIMITED. All rights reserved.
4f08c3bdfSopenharmony_ci * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com
5f08c3bdfSopenharmony_ci */
6f08c3bdfSopenharmony_ci#include <stdio.h>
7f08c3bdfSopenharmony_ci#include <stdlib.h>
8f08c3bdfSopenharmony_ci#include <string.h>
9f08c3bdfSopenharmony_ci#include <errno.h>
10f08c3bdfSopenharmony_ci#include <fcntl.h>
11f08c3bdfSopenharmony_ci
12f08c3bdfSopenharmony_ciint main(int argc, char **argv)
13f08c3bdfSopenharmony_ci{
14f08c3bdfSopenharmony_ci	int fd;
15f08c3bdfSopenharmony_ci
16f08c3bdfSopenharmony_ci	if (argc != 2) {
17f08c3bdfSopenharmony_ci		fprintf(stderr, "Only two arguments: %s <fd>\n", argv[0]);
18f08c3bdfSopenharmony_ci		exit(1);
19f08c3bdfSopenharmony_ci	}
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_ci	fd = atoi(argv[1]);
22f08c3bdfSopenharmony_ci	if (fcntl(fd, F_GETFL) < 0 && errno == EBADF)
23f08c3bdfSopenharmony_ci		return 0;
24f08c3bdfSopenharmony_ci
25f08c3bdfSopenharmony_ci	return 1;
26f08c3bdfSopenharmony_ci}
27

Indexes created Thu Nov 07 10:32:03 CST 2024