POSIX and ISC 2.2.x -- how many people are using this?

Heiko Blume src at scuzzy.in-berlin.de
Wed Apr 24 06:46:02 AEST 1991


alex at am.sublink.org (Alex Martelli) writes:

>src at scuzzy.in-berlin.de (I) wrote:
[i say that i made bash work with posix job control]

>Ah, just the man for me!-)  Being reasonably familiar with BSD job
>control, and having tried to gain understanding of Posix jc via the
>standards text and some discussions in the comp.std.unix archives, I
>find I must have failed, since when I tried to hack bash to posix jc
>on my Interactive 2.2 I got no results save a few shell hangs! I bet
>I'm not the only one in a similar predicament... would you like to
>enlighten us?  I think you can assume that BSD jc is understood,
>indeed jc-related diffs on Bash with a few theory pointers might be
>enough...
>I'll gratefully accept 'literature pointers' too, of course.

er, in fact i sort of hacked my way through it. ten zillion test
programs...the only documentation i had was the isc man pages and some
advise from the net, later i managed to get the standard ($100 - ugh).

i have posted my diffs for bash-1.05 to alt.sources in january, you should
be able to find them on some archive sites. those diffs weren't really
posix compliant though, but since bash-1.07 was announced shortly
after, i didn't post the better ones. unfortunately 1.07 still isn't out :-(

however, here's whats needed (on ISC 2.2.1) as far as i figured out:

- replace setjmp() and longjmp() with sigsetjmp() and siglongjmp().
  change the variables, casts etc of type jmp_buf to sigjmp_buf.
  sigsetjmp() needs a second argument specifying whether the signal
  mask shall be preserved or not. i always used '1' - preserve mask.

- replace ioctl(fd, TIOCSPGRP, &pgrp) with tcsetpgrp(fd, pgrp).

- replace setpgrp(pid, pgrp) with setpgid(pid, pgrp).

- replace killpg(pgrp, SIGNAL) with kill(-(pgrp), SIGNAL).

- the signaling functions need some intro: they work on 'objects'
  in the sense of an abstract data type, and must therefore be
  'created/initialized'. i.e. a 

    int oldmask = sigblock(1 << (SIGCHOKE-1))

  in BSD style job control translated to posix style jc is

    sigset_t oldmask, newmask;
    sigemptyset(&oldmask);					/* must initialize */
    sigemptyset(&newmask);
    sigaddset(&newmask, SIGCHOKE);			/* add signal to set */
    sigprocmask(SIG_BLOCK, &newmask, &oldmask);

  that looks very bloated, but it has it's advantages. especially
  the 32 signal limit that a (long) int imposes can be avoided.
  to restore the old signal mask replace the BSD

    sigsetmask(oldmask);

  with the posix call

    sigprocmask(SIG_SETMASK, &oldmask, (sigset_t *)0);

  a set of signals can be unblocked using SIG_UNBLOCK.
  to wait for one or more specific signals, BSD uses

    int mask=0;		/* any will do here */
    sigpause(mask);

  while posix suggests

    sigset_t nullmask;
    sigemptyset(&nullmask); /* any signal will do */
    sigsuspend(&nullmask); 

that's about it, i hope i didn't make any mistakes. as usual,
corrections are welcome.
-- 
   Heiko Blume <-+-> src at scuzzy.in-berlin.de <-+-> (+49 30) 691 88 93 [voice!]
                  public UNIX source archive [HST V.42bis]:
        scuzzy Any ACU,f 38400 6919520 gin:--gin: nuucp sword: nuucp
                     uucp scuzzy!/src/README /your/home



More information about the Comp.unix.sysv386 mailing list