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

2009-04-23 Thread Sandeep K Sinha
On Thu, Apr 23, 2009 at 2:20 AM, Greg Freemyer wrote: > On Wed, Apr 22, 2009 at 3:38 PM, Rohit Sharma wrote: >> Arun, i suggest that if you are using this for IPC then , better use pipes. >> >> And if you really want to use fd in another application then >> pass the file descriptor to exec after

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

2009-04-22 Thread Greg Freemyer
On Wed, Apr 22, 2009 at 3:38 PM, Rohit Sharma wrote: > Arun, i suggest that if you are using this for IPC then , better use pipes. > > And if you really want to use fd in another application then > pass the file descriptor to exec after doing a fork. > > something like this. > > in application_1 >

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

2009-04-22 Thread Rohit Sharma
Arun, i suggest that if you are using this for IPC then , better use pipes. And if you really want to use fd in another application then pass the file descriptor to exec after doing a fork. something like this. in application_1 ret = fork(); if(ret == 0){ sprintf(buff, "%d", fd_1); (void)exec(

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

2009-04-22 Thread Greg Freemyer
On Wed, Apr 22, 2009 at 5:12 AM, Arun raj wrote: > > On Wed, Apr 22, 2009 at 5:56 PM, pradeep singh > wrote: >> >> On Wed, Apr 22, 2009 at 1:33 PM, Arun raj >> wrote: >> > Hello All, >> > >> > I  want to use the file descriptor opened by  application_1 in another >> > application_2, i.e >> > >>

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

2009-04-22 Thread Sandeep K Sinha
pipes. On Wed, Apr 22, 2009 at 2:42 PM, Arun raj wrote: > Thanks a lot pradip. > > I would like to know  is  there any method/mechanism/logic to share > fd opened by application_1 which can be used in application_2. > > On Wed, Apr 22, 2009 at 5:56 PM, pradeep singh > wrote: >> >> On Wed, Apr 22

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

2009-04-22 Thread Hayim Shaul
1. I think application_2 can open the file /proc//fds/ 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, prad

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

2009-04-22 Thread Arun raj
Thanks a lot pradip. I would like to know is there any method/mechanism/logic to share fd opened by application_1 which can be used in application_2. On Wed, Apr 22, 2009 at 5:56 PM, pradeep singh wrote: > On Wed, Apr 22, 2009 at 1:33 PM, Arun raj > wrote: > > Hello All, > > > > I want to us

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

2009-04-22 Thread pradeep singh
On Wed, Apr 22, 2009 at 1:33 PM, Arun raj 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

Is it possible to use file descriptor after main returns

2009-04-22 Thread Arun raj
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 o