[comp.unix.programmer] pause

bhoughto@cmdnfs.intel.com (Blair P. Houghton) (10/31/90)

Is there a difference between `pause()' and `sigpause(0)'?

I can't see one.

Why obsoleted a perfectly simple system call with a
library function?

(BTW, neither of them is ANSI C; I don't know which might
be in POSIX).

				--Blair
				  "Golly.  Another one.  But then,
				   nobody ever answered my first..."

pfalstad@phoenix.Princeton.EDU (Paul John Falstad) (10/31/90)

In article <717@inews.intel.com> bhoughto@cmdnfs.intel.com (Blair P. Houghton) writes:
>Is there a difference between `pause()' and `sigpause(0)'?
>
>I can't see one.

Neither can I.  They're the other way around on my system, though (SunOS).
pause(3) and sigpause(2).

>Why obsoleted a perfectly simple system call with a
>library function?

What?

--
Paul Falstad, pfalstad@phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD
I would bring back hanging, and go into rope.  I would cut off the more
disreputable parts of the body and use the space for playing fields.

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (10/31/90)

In article <717@inews.intel.com> bhoughto@cmdnfs.intel.com (Blair P. Houghton) writes:
> Why obsoleted a perfectly simple system call with a
> library function?

Here it's pause(3) and sigpause(2). What machine are you using?

> (BTW, neither of them is ANSI C; I don't know which might
> be in POSIX).

POSIX imitated the BSD signal facilities, with some helpful additions.
It made sigpause() into sigsuspend(). The difference is that the
argument is a ``sigset_t'' manipulated by macros.

---Dan

bhoughto@cmdnfs.intel.com (Blair P. Houghton) (10/31/90)

In article <27817:Oct3104:58:4990@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
>In article <717@inews.intel.com> bhoughto@cmdnfs.intel.com (Blair P. Houghton) writes:
>> Why obsoleted a perfectly simple system call with a
>> library function?
>
>Here it's pause(3) and sigpause(2). What machine are you using?

A Dyslexia 1990 running Ungodlix -DDEBUG9...

I.e., it was a typo.

So was 'obsoleted', for you more confused readers out there...

>> (BTW, neither of them is ANSI C; I don't know which might
>> be in POSIX).
>
>POSIX imitated the BSD signal facilities, with some helpful additions.
>It made sigpause() into sigsuspend(). The difference is that the
>argument is a ``sigset_t'' manipulated by macros.

I've looked a little harder and tried a few more (seemingly
pathological) situations, and it seems `pause()' waits for
whatever signals are currently unblocked, and `sigpause(0)'
unblocks everything (only for the duration of the wait) and
then waits.  (sigpause(n) would use n as a signal mask).

				--Blair
				  "The wonders of skience."
				  -Popeye the Sailor Man

cowan@marob.masa.com (John Cowan) (11/01/90)

In article <717@inews.intel.com> bhoughto@cmdnfs.intel.com (Blair P. Houghton) writes:
>Is there a difference between `pause()' and `sigpause(0)'?
>
>I can't see one.
>
>Why obsoleted a perfectly simple system call with a
>library function?

As others have pointed out, pause(3) is the library routine and sigpause(2)
is the system call.  Pause used to be pause(2) on V7, but now is a
compatibility library routine calling sigpause(2).

Similar things have happened with exit(3), formerly exit(2) but now calling
_exit(2); alarm(3); signal(3); and so on.
-- 
cowan@marob.masa.com			(aka ...!hombre!marob!cowan)
			e'osai ko sarji la lojban

chris@mimsy.umd.edu (Chris Torek) (11/01/90)

In article <722@inews.intel.com> bhoughto@cmdnfs.intel.com
(Blair P. Houghton) writes:
>... it seems `pause()' waits for
>whatever signals are currently unblocked, and `sigpause(0)'
>unblocks everything (only for the duration of the wait) and
>then waits.  (sigpause(n) would use n as a signal mask).

Correct.  As the manual page states, sigpause(mask) atomically
sets the signal mask to `mask' and waits for a signal, then restores
the signal mask to whatever it was before.  pause() is effectively
equivalent to sigpause(sigblock((sigmask_t)0)).

(Use sigblock(0L) in old systems, or sigblock(0) if you do not care
about 2.10BSD.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris

chris@mimsy.umd.edu (Chris Torek) (11/01/90)

In article <27338@mimsy.umd.edu> I wrote:
>pause() is effectively equivalent to sigpause(sigblock((sigmask_t)0)).

Oops, that should be `sigset_t', not `sigmask_t'.  (Of course, many systems
have neither, which is why I suggested 0L or plain 0 as well.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris