LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-17-2011, 03:54 PM   #1
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 93

Rep: Reputation: 4
File-descriptors: redirection wanted


I need to redirect the process A's standard output to B's standard input.
Problem is A and B aren't directly related and can't be written down on the same pipeline of bash script (A | B).

Looking for solutions, I read about those file descriptors in /proc/<pid>/fd/ which promise to pipe directly into the process interface, but I did't get too much far.
If I push text trough any of them, that text apperas on the receiving process' console, but isn't interpreted, like if it was passed as output instead of as input.

In my concrete machine, B, the receiving process, is gimp-console, and A, the output-generator, is a generic script; other combinations of processes behaved the same way.

I noticed that file-descriptors 0 1 2 point to the same special-file; don't know if that's sane:

Code:
$ ls -l /proc/`pidof gimp-console`/fd/
total 0
lrwx------ 1 davide davide 64 Mar 17 20:48 0 -> /dev/pts/0
lrwx------ 1 davide davide 64 Mar 17 20:48 1 -> /dev/pts/0
l-wx------ 1 davide davide 64 Mar 17 20:48 10 -> pipe:[261933]
lrwx------ 1 davide davide 64 Mar 17 20:48 2 -> /dev/pts/0
lr-x------ 1 davide davide 64 Mar 17 20:48 3 -> pipe:[261925]
lr-x------ 1 davide davide 64 Mar 17 20:48 4 -> pipe:[261929]
l-wx------ 1 davide davide 64 Mar 17 20:48 5 -> pipe:[261929]
l-wx------ 1 davide davide 64 Mar 17 20:48 6 -> pipe:[261926]
lr-x------ 1 davide davide 64 Mar 17 20:48 7 -> pipe:[261932]

Last edited by romagnolo; 03-17-2011 at 03:59 PM.
 
Old 03-17-2011, 10:51 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,758

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Unless the application is expecting input from stdin I don't think what you're doing is going to work... happy to be corrected though. Descriptors 0,1 and 2 should map to stdin, stdout and stderr if that helps

cheers
 
Old 03-18-2011, 08:23 AM   #3
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 93

Original Poster
Rep: Reputation: 4
Obviously it does. Anyway, I could change my problem avoiding those links in /proc/<pid>/fd/ , relying on a regular bash pipe. Problem becomes: pipe must never break.
Gimp-console beheaves in two totally different ways whether it detects a pipe or not.
In the former case, gimp terminates as soon as stream ends; in the latter, it waits.
I have a raw workaround to keep the pipe opened, and so gimp: flood the stream with ininfluent data when nothin has to pass trough. For example by the means of:
$ yes some-ininfluent-data
with high nice value.

If you have better solutions in mind, please let me know. thanks.
 
  


Reply

Tags
pipe, redirection


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Descriptors matsko Linux - Software 2 04-24-2008 11:45 AM
File Descriptors during I/O Redirection joseamuniz Programming 2 02-27-2008 04:54 PM
file descriptors node047 Linux - Newbie 1 03-29-2005 05:47 AM
unix file descriptors versus c FILE pointers nodger Programming 9 11-25-2004 07:02 AM
BASH scripting: confused about redirection & file descriptors funkymunky Programming 1 06-07-2004 07:47 AM


All times are GMT -5. The time now is 07:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration