This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
2019-07-27 15:48:10 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include "../src/ipc.h"
|
|
|
|
#include "../src/usocket.h"
|
|
|
|
|
|
|
|
// This program opens a file then provide it to another running program.
|
|
|
|
// see examples/fd-exchange-receiving.c
|
|
|
|
|
2020-01-01 12:11:34 +01:00
|
|
|
int main (int argc, char *argv[])
|
2019-07-27 15:48:10 +02:00
|
|
|
{
|
|
|
|
if (argc != 2) {
|
|
|
|
fprintf (stderr, "usage: %s file", argv[0]);
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int sock = 0;
|
|
|
|
int fd = 0;
|
|
|
|
|
|
|
|
T_PERROR_R (((fd = open (argv[1], O_CREAT | O_RDWR)) < 0), "cannot open the file", EXIT_FAILURE);
|
|
|
|
|
2023-01-03 12:09:28 +01:00
|
|
|
TEST_IPC_Q (usock_connect (&sock, "./SOCKET_FD_EXCHANGE_TEST"), EXIT_FAILURE);
|
2020-01-01 12:11:34 +01:00
|
|
|
TEST_IPC_Q (ipc_provide_fd (sock, fd), EXIT_FAILURE);
|
2019-07-27 15:48:10 +02:00
|
|
|
|
2020-01-01 12:11:34 +01:00
|
|
|
return EXIT_SUCCESS;
|
2019-07-27 15:48:10 +02:00
|
|
|
}
|