#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <stdio.h>
#include <stropts.h>
#include <sys/conf.h>
#include <unistd.h>
#include <stdlib.h>
#define SPIPE_PATH "/tmp/mypipe"
int
main(void)
{
int serverfd;
struct strrecvfd strrecvfd;
/*
* Open a connection to the server.
*/
serverfd = open(SPIPE_PATH, O_RDWR);
if (serverfd == -1) {
perror("open");
return (EXIT_FAILURE);
}
/*
* Receive the STREAMS descriptor from the server.
*/
if (ioctl(serverfd, I_RECVFD, &strrecvfd) == -1) {
perror("ioctl (I_RECVFD)");
return (EXIT_FAILURE);
}
(void) printf("received the STREAMS descriptor; attempting to pop "
"the top module\n");
/*
* Try to remove the top module from the stream.
*/
if (ioctl(strrecvfd.fd, I_POP, 0) == -1)
perror("ioctl (I_POP)");
(void) printf("modules on the stream: ");
(void) fflush(stdout);
/*
* Print out what the stream currently looks like.
*/
(void) dup2(strrecvfd.fd, 0);
(void) system("strconf | paste -s -d' ' -");
return (EXIT_SUCCESS);
}
|