jayduhon / inferno-os

Automatically exported from code.google.com/p/inferno-os
2 stars 0 forks source link

Linux, FreeBSD: emu killed on exit #282

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
  Ubuntu 12.04 $ emu echo ok
  ok
  Killed
  Ubuntu 12.04 $

  FreeBSD 8.0 $ emu-g echo ok
  ok
  Killed
  FreeBSD 8.0 $ 

What is the expected output? What do you see instead?
I'm expect to not see "Killed" on emu shutdown. In MacOSX and Win there is no 
"Killed", it happens only on Linux and FreeBSD.

Which operating system are you using?
Tested on Linux, FreeBSD, MacOSX and Win.

Please provide any additional information below.
I've found a work around some time ago - wrapper script in ~/bin/emu.
Linux version:
  #!/bin/bash
  $INFERNO_ROOT/Linux/386/bin/emu "$@" </dev/stdin &
  wait 2>/dev/null
FreeBSD version:
  #!/usr/local/bin/bash
  $INFERNO_ROOT/FreeBSD/386/bin/emu "$@" </dev/stdin &
  wait 2>/dev/null

Original issue reported on code.google.com by powerman...@gmail.com on 17 Jun 2012 at 5:18

GoogleCodeExporter commented 9 years ago
In several emu/*/os.c (most of the *nix except MacOSX, Solaris, and Unixware at 
1st look), the function "cleanexit" does a "kill(0, SIGKILL)" before calling 
"exit(0)".

I'm afraid to remove the "kill(0, SIGKILL)" w/o understanding why it's there, 
but I believe that's the reason why the "Killed" message appears.

Original comment by joseph.s...@gmail.com on 7 Jun 2013 at 3:44

GoogleCodeExporter commented 9 years ago
That is the reason for the message, but at the moment the kill is needed to
shut down the various processes (eg, running kprocs) without having to 
enumerate them
(which would be fairly involved, and anyway, this is a good use of a process 
group).

Cleanexit sends the signal to the process group. The cleanexit function is not 
necessarily
called in the process for which the shell is waiting, so that process is hit by
the SIGKILL, and the shell prints the diagnostic. Something along those lines.

Original comment by Charles....@gmail.com on 7 Jun 2013 at 3:50

GoogleCodeExporter commented 9 years ago
I understand Alex' issue with this, as I too will use emu inside shell scripts 
and the "Killed" message makes things a bit messy at the console.

It also makes sense to not clutter up the code with kproc tracking details for 
such a minor issue.

Is the lack of "kill(0, SIGKILL)" in the other *nix platforms an oversight or 
by design?

I will research if there are any clever ways to suppress the SIGKILL message.

Original comment by joseph.s...@gmail.com on 7 Jun 2013 at 6:48

GoogleCodeExporter commented 9 years ago
Oh, I quite agree with you about the messiness. I was just explaining what it 
was doing, not suggesting that was the way it ought to be left.

Also, nearly all the Unix platforms (I thought it was all of them) have kill(0, 
SIGKILL) or an equivalent. Try cd emu; grep SIGKILL */os.c

Original comment by Charles....@gmail.com on 7 Jun 2013 at 9:04