Paul L. Snyder on 30 Jan 2009 09:05:23 -0800

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] idle curiosity - ghost process

On Fri, 30 Jan 2009, Stephen Gran wrote:

> On Fri, Jan 30, 2009 at 11:25:14AM -0500, Bill East said:
> > root@flows:/etc# grep ETH0 &
> > (sorry) and I get to wondering, what could I do with this? Could I
> > potentially pipe output to it, or is it unreachable?

> You're looking for 'help fg' and the JOB CONTROL section of the bash man
> page.

What Stephen said.

As grep was waiting on stdin, once it was backgrounded the process will
have suspended.  You probably saw something like:

  % grep ETH0 &
  [1] 4870
  [1]  + 4870 suspended (tty input)  grep ETH0

'1' is the job number and '4870' is the pid, so if you want to do something
with the process you don't need to run 'ps'; you can reference it as '%1',

  % kill %1

If it's the only grep process the shell has started you can refence by
name, like

  % kill %grep

or even

  % kill %g

> I guess it would
> > still write to stdout, so anything it did output would still come up
> > on my tty.

If you wanted to do something with a backgrounded grep process, you could

  % mkfifo foo
  % grep eth0 foo &
  [1] 4971
  % dmesg > foo

> Are there any tips or tricks for dealing with forked
> > processes, or should I just kill -9 it and get on with my work?

You shouldn't need to 'kill -9' it; the SIGINT sent by a simple kill
should suffice.

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --