stdout/stderr/???
Richard Lynch
ceo at l-i-e.com
Sun Oct 10 14:01:12 PDT 2004
Malcolm Kay wrote:
> On Sun, 10 Oct 2004 06:53 am, Richard Lynch wrote:
>> I have a situation where NIC code printf's out stuff.
>>
>> I'd *LIKE* to collect that output.
>>
>> Under Linux, I'd use 2&>1
>
> I think (hope) you mean 2>&1
According to "man bash" both should work, though one is preferred.
Both work fine *EXCEPT* that I have to pull the plug, and the file never
gets save/written/whatever.
I am using bash, specifically so I *CAN* do re-directs, but would be happy
to use *ANY* shell if I could just get what I want.
> Can't see why it should work differently for 'ifconfig'
> unless maybe this time you have the '&' in the wrong place.
> In any case I would not expect massive amounts of output from
> ifconfig.
It works differently because the driver goes into an infinite loop, and
the file never manages to get written. Perhaps I could reduce some kind
of buffer somewhere to force the flush() to the file?
>> I can sorta get what I want by starting X-Windows, and using a
>> terminal/shell to do the command. Then the messages I desire to log are
>> A) suppressed from by shell (which is BAD) but B) logged into
>> /var/log/messages (which is close enough to what I want)
>
> I don't understand what you are saying here. X-windows (of itself) should
> not process the commands differently. I suspect you have some fancy
> desktop
> program with options set that interfere.
It's KDE.
I'll be damned if I know why it's re-directing stderr to /var/log/messages
and hiding it from me in the shell.
I've tried poking around in the configuration of shells, but am presented
with a dialog so confusing, with so many options, I can't even understand
what all the choices mean. :-(
All I really want is a shell just like CTRL-ALT-F#. Except it would be
nice if shift-ctrl-c and shift-ctrl-v did copy/paste. I have that on one
X shell on a RedHat 9 box, and it's pretty nice. All the other copy/paste
options are cumbersome, at best, and frequently just plain won't cross
applications boundaries. (IE, I can copy/paste from shell to shell, but
not shell to browser. Grrrrrr)
>> Alas, the real problem comes when my driver code sends the machine into
>> an
>> infinite loop, spewing out messages so fast I can't even read them, and
>> the only way out is to forcibly power-off the laptop by removing battery
>> and power cord.
>
> What driver code? Are you trying to write your own? for what device?
I am attempting to modify /usr/src/sys/dev/bfe/if_bfe.c to work with the
Broadcom 4401-B0 in my laptop.
The existing code is known to work for the Broadcom 4401-A1.
> An infinite loop while running or compiling the driver code?
>
> If when the driver code is installed and run then you are fiddling will
> kernel mode, and if you mess up all bets are off.
bfe has been disabled in the kernel, and the kernel has been
re-built/installed.
cd /usr/src/sys/modules/bfe/
make; make install; kldload /boot/kernel/if_bfe.ko;
"ifconfig bfe0" works fine, and prints out my error messages, and I can
capture them.
"ifconfig bfe0 192.168.2.111" generates an infinite loop spewing messages
so fast I can't even *READ* them.
Nothing but total power loss stops this.
> You have tried Cntrl-Z and Cntrl-Alt-F2 ?
Ctrl-Z I have not tried.
cntrl-alt-f2, hit repeatedly, will eventually "catch" an interrupt (or
time-slice or whatever) and get me to tty2. But I can't seem to do
anything useful there, as keyboard input is ignored. I could, perhaps,
manage to press a key long enough to catch an interrupt/time-slice
there...
>> Upon re-boot, the additions I would expect in /var/log/messages (or the
>> bziped older logs) do not contain the messages I need to see.
>>
>> I have also tried:
>> ktrace xxx
>>
>> Again, for the case where the machine is not in an infinite loop, it
>> works
>> real nifty; But when I'm forced to chop power, I get nothing.
>>
>> Is there something that will:
>> A) copy (or re-direct) all output somewhere, *AND*
>> B) force it to be synchronous and unbuffered and whatever else has to
>> occur to get the file to be saved?
>>
>> Any other suggestions for how to get this process to not lock up the
>> machine? control-C ineffective
>> CTRL-ALT-F2 followed by CTRL-ALT-DELETE can sometimes get me to another
>> tty, but that tty does not accept input
>
> Are you sure?
Yes, I'm quite sure.
I can switch back to ctrl-alt-f1, but cannot log in.
I can press ctrl-alt-f2 enough times, and eventually get switched to
tty2... which is dead.
> The CTRL-ALT-F2 hopefully gets you a character mode tty with a login
> prompt.
> But you'll need to login to proceed. CTRL-ALT-DELETE at this stage should
> cause a reboot.
ctrl-alt-delete does absolutely nothing, though perhaps if I held it down
long enough to catch a time-slice (or interrupt or whatever) it *MIGHT*
re-boot. Probably not much better than cold power loss, though, right?
--
Like Music?
http://l-i-e.com/artists.htm
More information about the freebsd-questions
mailing list