1 /* Common code for message queue passing tests.
2 Copyright (C) 2004-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
27 static int temp_mq_fd
;
29 /* Add temporary files in list. */
31 __attribute__ ((unused
))
32 add_temp_mq (const char *name
)
35 iov
[0].iov_base
= (char *) name
;
36 iov
[0].iov_len
= strlen (name
);
37 iov
[1].iov_base
= (char *) "\n";
39 if (writev (temp_mq_fd
, iov
, 2) != iov
[0].iov_len
+ 1)
40 printf ("Could not record temp mq filename %s\n", name
);
43 /* Delete all temporary message queues. */
47 if (lseek (temp_mq_fd
, 0, SEEK_SET
) != 0)
50 FILE *f
= fdopen (temp_mq_fd
, "r");
57 while ((rets
= getline (&line
, &n
, f
)) > 0)
59 if (line
[rets
- 1] != '\n')
62 line
[rets
- 1] = '\0';
71 char name
[] = "/tmp/tst-mqueueN.XXXXXX";
72 temp_mq_fd
= mkstemp (name
);
75 printf ("Could not create temporary file %s: %m\n", name
);
81 #define PREPARE(argc, argv) do_prepare ()
82 #define CLEANUP_HANDLER do_cleanup ()