tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* Why does a simple named pipe does not work. I am doing some thing wrong
@ 2001-04-27 19:15 Gadde, Srinivas
  0 siblings, 0 replies; only message in thread
From: Gadde, Srinivas @ 2001-04-27 19:15 UTC (permalink / raw)
  To: tru64-unix-managers


A.c
---

# cat A.c

#include        <stdarg.h>

#include <fstab.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/ioctl.h>
#include <sys/procfs.h>
#include <errno.h>

#define         SERVER_PIPE
"/etc/fr34/sockdir/dldsrvr.pipe"

main ()
{
  int             dm_fd;
  int             ld_fd[2] = {-1,-1};
  int             io_rc;
  int             Rc;

  errno = 0;
  dm_fd = open(SERVER_PIPE,O_RDWR,0666);
  printf ("open %d\n", dm_fd);
  errno = 0;
  Rc = pipe(ld_fd);
  printf ("RC=%d ld_fd[0]=%d ld_fd[1]=%d\n", Rc, ld_fd[0], ld_fd[1]); 
  do {
  errno = 0;
  io_rc = ioctl(dm_fd,I_SENDFD,ld_fd[1]);
  printf ("I_SENDFD ioctl returned %d errno %d\n", io_rc, errno); 
  sleep (5);
  } while (io_rc != 0);
  pause ();
}/* end of main */
# 

Second Program B.c !!!!!!!!!!!!!!!!!!!!!! Starts Here !!!!!!!!!!!!!

# cat B.c

#include        <stdarg.h>

#include <fstab.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/ioctl.h>
#include <sys/procfs.h>
#include <sys/stropts.h> /* Added in the sample */
#include <errno.h>

#define         SERVER_PIPE
"/etc/fr34/sockdir/dldsrvr.pipe"

main ()
{
  int             Sd;
  int             Rc;
  struct  strrecvfd       Fds;

  Sd = open(SERVER_PIPE,O_RDWR,0666);
  printf ("open %d\n", Sd);
  errno = 0;
  
  Rc = fattach(Sd,SERVER_PIPE);
  printf ("fattach with Rc %d errno %d\n", Rc, errno);
  errno = 0;
do{
  Rc = ioctl(Sd,I_RECVFD,&Fds);
  printf ("I_RECVFD ioctl Rc %d errno %d\n", Rc, errno);
  sleep (5);
} while (Rc != 0);
  pause ();
}/* end of main */



	 -----Original Message-----
	From: 	Gadde, Srinivas  
	Sent:	Friday, April 27, 2001 12:21 PM
	To:	'tru64-unix-managers@ornl.gov'
	Cc:	Gadde, Srinivas
	Subject:	A small question on named pipes

	Hello,

		I am porting a named pipe based applications and I am
getting
	an errno 16 which is "EBUSY" from ioctl (fd, I_SENDFD, pipe[1])
	and also on other program from ioctl(fd,I_RECVFD, pipe[1])

	1). I created the named pipe with "mknod server.pipe p" command
	2). in Program A

	   functionA()
	{
	        int             dm_fd;
	        int             ld_fd[2] = {-1,-1};  
	.
	.
	.

		dm_fd = open(SERVER_PIPE,O_RDWR,0666);
		Rc = pipe(ld_fd);    
	.
	.
	.
	         write(ld_fd[0],Request,sizeof(struct command_s)); /* This
may be out of sequence, I don't know ,
								But I am
writing on 0 */
	.
	.
		io_rc = ioctl(dm_fd,I_SENDFD,ld_fd[1]);     

	            /* I get an errno 16 (EBUSY) */

	}

	In Program B

	FunctionB ()
	{
	int Sd;  
	struct  strrecvfd       Fds; 

	Sd = open(SERVER_PIPE,O_RDWR,0666);
	.
	.
	fattach(Sd,SERVER_PIPE);   
	.
	.
	Rc = ioctl(Sd,I_RECVFD,&Fds);
	/* I get an error EBUSY errno 16 */

	}


	Any help is greatly appreciated.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-04-27 19:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-27 19:15 Why does a simple named pipe does not work. I am doing some thing wrong Gadde, Srinivas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox