Re: Signal handling question

2009-10-18 Thread Otto Moerbeek
On Sat, Oct 17, 2009 at 08:45:39PM -0700, Philip Guenther wrote:

[snip]

 If they lack research like this one, I don't want to see them either.


Thanks Philip, you just wrote what I was going to write. 

Any diff, and signal diffs even more so, requires understanding of
what you are changing.

-Otto



Re: Signal handling question

2009-10-18 Thread Matt Fisher
On Sat, 17 Oct 2009 20:45:39 -0700
Philip Guenther guent...@gmail.com wrote:

Many solid points and:

If the answers to those questions are yes, then you should say so
and back it up.  If not, why should we apply a diff to remove code
from someone who doesn't know why the code is there?  As is, I believe
you don't understand why that code was added, don't understand when it
was triggered, and don't know whether or not it could still be
triggered.

Although I'd rather crawl under a rock, I'll respond.

You're correct. I got started on this train of thought after reading
an old USENIX paper[1]. The line I suggested for deletion is identical
to what section 1.2.1 of that paper recommended should always be
included. Recent material continues to recommend such code, but not
specifically in OpenBSD[2],[3].

Since such code is only rarely used in OpenBSD -- 9 occurrences in the
whole tree -- I thought it might be an obsolete or inapplicable
recommendation. One such occurrence was in m4/main.c, so I contacted the
developer who had recently checked in that file.

I did read manuals, study code, consider, and test first. But I knew my
expertise was limited, and that there could be other considerations.
I never said imperatively delete this. I asked Stuart if it was a
valid change. To you, I said it was possible cruft.

It's good that you are circumspect. Frankly, I was expecting the answer
to be known. But if it's doubtful, the change has to be rejected.

[1] http://www.darwinsys.com/history/canthappen.html
[2] http://oreilly.com/catalog/9780596009588
[3] 
http://www.cs.princeton.edu/courses/archive/spr06/cos217/lectures/23signals.pdf
-- 
Matt Fisher mfisher...@maine.rr.com



kernel make file doesn't have dependency for bsd for the install target

2009-10-18 Thread Han Boetes
Hi,

I just ran tried to install the kernel and ran:

  make depend
  make install

Since I forgot running make and since there is no dependency for
bsd the target removed my old kernel without installing the new
one.

How about this patch for the i386 target?

cvs server: Diffing .
Index: Makefile.i386
===
RCS file: /cvs/src/sys/arch/i386/conf/Makefile.i386,v
retrieving revision 1.51
diff -u -p -r1.51 Makefile.i386
--- Makefile.i386   11 Jan 2009 21:02:03 -  1.51
+++ Makefile.i386   18 Oct 2009 19:48:41 -
@@ -190,7 +190,7 @@ locore.o: ${I386}/i386/locore.s assym.h
 MACHINE_NAME!=  uname -n
 install: install-kernel-${MACHINE_NAME}
 .if !target(install-kernel-${MACHINE_NAME}})
-install-kernel-${MACHINE_NAME}:
+install-kernel-${MACHINE_NAME}: bsd
rm -f /obsd
ln /bsd /obsd
cp bsd /nbsd



# Han



Re: Signal handling question

2009-10-18 Thread Philip Guenther
On Sun, Oct 18, 2009 at 12:49 AM, Matt Fisher mfisher...@maine.rr.com wrote:
 You're correct. I got started on this train of thought after reading
 an old USENIX paper[1]. The line I suggested for deletion is identical
 to what section 1.2.1 of that paper recommended should always be
 included. Recent material continues to recommend such code, but not
 specifically in OpenBSD[2],[3].

 Since such code is only rarely used in OpenBSD -- 9 occurrences in the
 whole tree -- I thought it might be an obsolete or inapplicable
 recommendation. One such occurrence was in m4/main.c, so I contacted the
 developer who had recently checked in that file.

 I did read manuals, study code, consider, and test first. But I knew my
 expertise was limited, and that there could be other considerations.

If all you have is a chunk of code that you don't understand the
justification for, you have to work backwards to the problem.  This
can turn into the programming equivalent of disproving an existential,
for which having a broad base of experience really helps.  How do you
get that base of experience?  Well, start by tackling concrete
problems (program behaves incorrectly when I try blah) instead of
jumping straight to the abstract cases.

That, or you need to crank up your methodology and logic.  The code in
this case applies only when the process is started with SIGINT set to
SIG_IGN.  If the process was set by its parent to ignore SIGINT, why
would it start paying attention to them now by catching them?  Doing
that might be fine if that was something that used to be normal
practice but never happened nowadays.  So what programs did that in
the past?  Didn't the paper say something about running stuff in the
background from the shell with ?  So let's check the sh(1) manpage
to see what it says now:
 When an asynchronous command is started when job
 control is disabled (i.e. in most scripts), the command is started with
 signals SIGINT and SIGQUIT ignored

Looks like the shell still does that.  A little bit of noodling shows
that this snippet of shell script
#!/bin/sh
( : ; /some/program/here ) 

Invokes /some/program/here with SIGINT ignored.

So, it looks like running m4 in the background from a shell script
will still result in it being invoked with SIGINT set to SIG_IGN.  In
such a case, if you interrupted the shell script using SIGINT,
shouldn't m4 ignore the signal and continue?  It would continue if the
shell script exited normally, so why should signaling the script
terminate it?  Ergo, I think this code is correct and should be left
as is.

You wonder why only 9 programs in the tree have such code.  Well, how
programs does this problem apply to?  It doesn't apply to any program
that calls daemon(), for example, as they won't get SIGINTs a
terminal.  So rpc.statd's signal handling is fine, for example.  It
also doesn't apply to programs that can't be usefully backgrounded, so
'rain' is fine as is.

But it looks like some programs do handle it wrong and could use
fixing.  For example, 'sort' appears to be wrong...but before I wrote
that I figured out how to trigger the problem, both to confirm it and
to verify the fix.  Make sense?

Philip Guenther


--- sort.c  22 Aug 2007 06:56:40 -  1.36
+++ sort.c  18 Oct 2009 22:44:47 -
@@ -273,7 +273,7 @@ main(int argc, char *argv[])
outfile = outpath = toutpath;
} else if (!(ch = access(outpath, 0)) 
strncmp(_PATH_DEV, outpath, 5)) {
-   struct sigaction act;
+   struct sigaction oact, act;
int sigtable[] = {SIGHUP, SIGINT, SIGPIPE, SIGXCPU, SIGXFSZ,
SIGVTALRM, SIGPROF, 0};
int outfd;
@@ -298,7 +298,9 @@ main(int argc, char *argv[])
act.sa_flags = SA_RESTART;
act.sa_handler = onsig;
for (i = 0; sigtable[i]; ++i)   /* always unlink toutpath */
-   sigaction(sigtable[i], act, 0);
+   if (sigaction(sigtable[i], NULL, oact) ||
+   oact.sa_handler != SIG_IGN)
+   sigaction(sigtable[i], act, NULL);
} else
outfile = outpath;
if (outfp == NULL  (outfp = fopen(outfile, w)) == NULL)



Como vencer na vida? SABER COMANDAR E SABER INSTRUIR.

2009-10-18 Thread as1780...@sapo.pt
MAIL ERROR