in reply to Re: unexplained output from top in batch mode
in thread unexplained output from top in batch mode

Well, if you use the script in ztk-visual-top-w-kill, and go into the thread where I sysread top's output. and print the $buf,
sysread(READ,$buf,8192); print "$buf\n\n";
you will see that top's batch output is setting the name to 3 (at least on my machine for /home/zentara/bin/claws), when it's still a string, before any split occurs.

So the question is whether it is top's -b option that does this, or does the IPC::Open3 pipe somehow change it?

When top is run in normal mode(like in an xterm), the name is shown correctly.

Also if I do "top -b >>top.output", the name is shown correctly as "claws". So somehow, coming thru the IPC::OPen3 pipe is causing it to change. Is it possible that a pipe is interpreted to be a weird terminal type (not vt100)?


I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^3: unexplained output from top in batch mode
by jettero (Monsignor) on Jan 13, 2007 at 13:53 UTC

    K, then I stand by my previous guess. Sometimes columns can have embedded spaces (like the leading spaces on RES and SHR, etc), and I think that might be messing up your column numbers. If it's just the one process getting renamed, I'd look for something stranger going on, but somehow I think it's going to relate to split /\s+/

    -Paul

      Thanks for looking at it, but now I think it is something weird with Claws output. When I look at the entry for the pid in /proc, the name is different in different places. In /proc/$pid/cmdline, it is correctly shown as 'claws'. But in /proc/$pid/status, it shows it's Name as 3. So I think it is a problem with Sylpheed-Claw's way of reporting iteslf? Every other process seems to have Name and cmdline as the same (or similar).

      I'm not really a human, but I play one on earth. Cogito ergo sum a bum
        Hrm, my leading spaces comment doesn't really make any sense looking back, but I was just rejecting the idea it had to do with open3. The problem really has to be with the way top is reading the procs or the way you're parsing it.

        Pretty sure you can set cmdline with $0, which is probably what claws is doing (or the C analog or whatever), but I'm really not sure what /status is set from. I seem to recall it comes from something else.

        -Paul