[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug?] Trouble with fgets from popen
From: |
Carnë Draug |
Subject: |
[bug?] Trouble with fgets from popen |
Date: |
Wed, 25 Aug 2010 20:19:15 +0100 |
Hi
I can't get fgets to read the last input from a pipe open with popen.
>From reading the help text, I think it should return -1 when it has
read everything but instead it just hangs.
The process started is "zenity --scale --print-partial". This creates
a GUI of a scale bar that can be adjusted. Every time, the bar is
adjusted (even without pressing the OK button), it prints the selected
value. By experimenting in a terminal (and by setting fgets to read
only one character at a time), I can see that zenity does print the
number as soon as the bar is adjusted and not after the next one is
selected
This should replicate it:
octave-3.2.4:109> fid = ("zenity --scale --print-partial", "r")
## adjust bar to value 16
## adjust bar to value 24
octave-3.2.4:110> fgets(fid)
ans = 16
octave-3.2.4:111> fgets(fid)
## octave hangs
## adjust bar to value 46
ans = 24
octave-3.2.4:112> fgets(fid)
## octave hangs
## press OK on the zenity dialog
ans = 46
This shows that the number is in the pipe:
octave-3.2.4:113> fid = ("zenity --scale --print-partial", "r")
## adjust bar to value 16
octave-3.2.4:114> fgets(fid,1)
ans = 1
octave-3.2.4:114> fgets(fid,1)
ans = 6
octave-3.2.4:114> fgets(fid,1)
## octave hangs instead of returning -1
Any help is very appreciated,
Carnë Draug
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug?] Trouble with fgets from popen,
Carnë Draug <=