Re: different processes using same file object

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

 



there are 2 completely different processes A and B
process A opens a file with fd 4
then i change the 'fs' and 'files' fields of the process descriptor of proc B to point to the respective fields of proc A
( i.e i let proc B share the  2 tables from proc A)
then proc B opens a file  with fd 5
then proc B does a dup2(5,4) sys call .            //dup2(oldfd,newfd)
 
so would proc A be reading/writing the contents of fd=5(file opened by proc B) when it does a read/write on fd=4(file opened by proc A)?


On Tue, Sep 29, 2009 at 3:48 PM, krushnaal pai <krisonearth@xxxxxxxxx> wrote:
even if process A does recv the file descriptions thru sockets how will it use the file object of process B?


On Tue, Sep 29, 2009 at 2:58 PM, Luciano Rocha <luciano@xxxxxxxxxxx> wrote:
On Tue, Sep 29, 2009 at 02:20:00PM +0530, krushnaal pai wrote:
> i have 2 completely different processes A and B (they do not have any
> relationship)
>
> suppose A opens a file with file descriptor 4 and
> B opens another file with file descriptor 5
>
> can process A use the fd 5 (i.e using the file object of processs B) by any
> means..

You can pass file descriptions using unix sockets. Check "man 7 unix"
for instructions.

> if suppose i let the fd 4 of process A to point to the file object of
> process B(fd 5)
>
> will it work?

No. They will not share the file descriptor (offsets, flags, mode etc.
will not be shared).


--
Luciano Rocha <luciano@xxxxxxxxxxx>
Eurotux Informática, S.A. <http://www.eurotux.com/>



[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