xref: /illumos-gate/usr/src/test/libc-tests/tests/posix_spawn/getsid.c (revision 35e0963c135e57db23f111dfe9dbf1dae97a9fc3)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2025 Oxide Computer Company
14  */
15 
16 #include <stdlib.h>
17 #include <unistd.h>
18 
19 int
20 main(void)
21 {
22 	pid_t pg = getpgid(0);
23 	pid_t sid = getsid(0);
24 
25 	if (write(STDOUT_FILENO, &sid, sizeof (sid)) != sizeof (sid)) {
26 		return (EXIT_FAILURE);
27 	}
28 
29 	if (write(STDOUT_FILENO, &pg, sizeof (pg)) != sizeof (pg)) {
30 		return (EXIT_FAILURE);
31 	}
32 
33 	return (EXIT_SUCCESS);
34 }
35