Re: Is it possible to use file descriptor after main returns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



1. I think application_2 can open the file /proc/<app_1-PID>/fds/<fd_1>
but then they are not really sharing the same fd but merely opening the
same file

 
2. you can try looking at http://phook.sourceforge.net/ they use ptrace
to read/write from another process fd

Hayim.


On Wed, 2009-04-22 at 14:26 +0530, pradeep singh wrote:
> On Wed, Apr 22, 2009 at 1:33 PM, Arun raj <arun.raj.linux@xxxxxxxxx> wrote:
> > Hello All,
> >
> > I  want to use the file descriptor opened by  application_1 in another
> > application_2, i.e
> >
> > ./application_1 :
> > main()
> > {
> >     fd_1 = open( file );
> >     return fd_1;
> > }
> >
> > ./application_2  fd_1
> > main()
> > {
> >     ret = read( fd_1 );
> >     return fd;
> > }
> >
> > My concern is once application_1 main returns all open fds will be closed
> > right ?
> 
> Right. So better try to fork a new process or create a new thread,
> that way you may share the same fd between them.
> Once you have the fd, do whatever you want to do with it.
> 
> Si this what you want ?
> 
> HTH
> >
> > Thanks in advance .
> >
> > Thanks,
> > A.R
> >
> >
> 
> 
> 


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux