Commit Graph

182 Commits

Author SHA1 Message Date
Michael Kerrisk faa64f705b Setup for 2.02 release. 2005-04-05 06:55:35 +00:00
Michael Kerrisk e8a095046c Updates for 2.02 release. 2005-04-05 06:44:35 +00:00
Michael Kerrisk 7c088cb1d8 Date: Fri, 28 Jan 2005 11:00:59 +0000
From: Jamie Lokier <jamie@shareable.org>
To: mtk-manpages@gmx.net
Subject: Update to fcntl(2) man page

Hi Michael,

I have a correction to the fcntl(2) man page.

Under the section for F_SETOWN, which describes how to set the
recipient process or group for SIGIO signals, see this paragraph:

	The process or process  group  to  receive  the  signal  can  be
	selected  by  using  the F_SETOWN command to the fcntl function.
	If the file descriptor is a socket, this also selects the recip-
	ient  of SIGURG signals that are delivered when out-of-band data
	arrives on that socket.  (SIGURG is sent in any situation  where
	select(2) would report the socket as having an "exceptional con-
	dition".)  If the file  descriptor  corresponds  to  a  terminal
	device,  then  SIGIO  signals are sent to the foreground process
	group of the terminal.

I would like to add an additional paragraph:

	The value given to F_SETOWN has a slightly different meaning
	when F_SETSIG is used in a multi-threaded process.

	If a non-zero value is given to F_SETSIG, then a positive
	value given to F_SETOWN identifies a specific thread within a
	process, instead of a whole process.  The value is a thread id
	not a process id, so you may need to pass the result of
	gettid() instead of getpid() to get sensible results when
	F_SETSIG is used.  (Thread ids are different from process ids,
	although they have the same value for some threads depending
	on details of the threading library used).

Also, this is the first paragraph of the F_SETSIG section:

	Sets the signal sent when input or output becomes  possible.   A
	value of zero means to send the default SIGIO signal.  Any other
	value (including SIGIO) is the signal to send  instead,  and  in
	this  case additional info is available to the signal handler if
	installed with SA_SIGINFO.

I'd like to append another paragraph right after that one:

	Additionally, passing a non-zero value to F_SETSIG changes the
	signal recipient from a whole process to a specific thread
	within a process.  The section on F_SETOWN gives more details.


Date: Thu, 7 Apr 2005 17:58:59 +0100
From: Jamie Lokier <jamie@shareable.org>
To: Michael Kerrisk <mtk-manpages@gmx.net>
Subject: Re: Update to fcntl(2) man page

[[...]]

> I've been trying to follow the kernel source code to verify
> the details you describe above.  The relevant place is the 
> 'switch' in fs/fcntl.c::send_sigio_to_task() right?

Yes.

> Also, for NPTL, perhaps one needs to mention that for the main
> thread, gettid() == getpid(), which allows the traditional
> use of F_SETSIG / F_SETOWN in programs consisting of a single
> thread -- right?

Yes, that makes sense.  It's also fine for the "main thread" with
NPTL, so programs which spawn threads can still use F_SETOWN/F_SETSIG
in the main thread using getpid().


Date: Tue, 12 Apr 2005 15:25:49 +0100
From: Jamie Lokier <jamie@shareable.org>
To: Michael Kerrisk <mtk-manpages@gmx.net>
Subject: Re: Update to fcntl(2) man page

Michael Kerrisk wrote:
>   F_SETOWN
>          Set  the  process ID or process group ID that will
>          receive SIGIO and SIGURG  signals  for  events  on
>          file  descriptor fd.  A process ID is specified as
>          a positive value; a process group ID is  specified
>          as a negative value.
> 
>          If  you  set  the  O_ASYNC  status  flag on a file
>          descriptor (either by providing this flag with the
>          open(2)  call,  or by using the F_SETFL command of
>          fcntl), a SIGIO signal is sent whenever  input  or
>          output  becomes  possible on that file descriptor.
>          F_SETSIG can be used to obtain delivery of a  sig&#8208;
>          nal other than SIGIO.
> 
>          If  the  file  descriptor  fd  refers to a socket,
>          F_SETOWN also selects the recipient of SIGURG sig&#8208;
>          nals  that  are  delivered  when  out-of-band data
>          arrives on that socket.  (SIGURG is  sent  in  any
>          situation  where select(2) would report the socket
>          as having an "exceptional condition".)
> 
>          If a non-zero value is  given  to  F_SETSIG  in  a
>          multi-threaded  process,  then  a  positive  value
>          value given to F_SETOWN has a  different  meaning:
>          instead  of being a process ID identifying a whole
>          process, it is a thread ID identifying a  specific
>          thread  within a process.  Consequently, it may be
>          necessary to pass F_SETOWN the result of  gettid()
>          instead  of  getpid() to get sensible results when
>          F_SETSIG is used.   (In  current  Linux  threading
>          implementations,  a main thread's thread ID is the
>          same as its process ID.  This means that a single-
>          threaded  program can equally use gettid() or get&#8208;
>          pid() in this scenario.)  Note, however, that  the
>          statements  in  this paragraph do not apply to the
>          SIGURG signal generated for out-of-band data on  a
>          socket:  this  signal  is  always sent to either a
>          process or a process group, depending on the value
>          given to F_SETOWN.
> 
> And the first part of the description of F_SETSIG now reads:
> 
>   F_SETSIG
>          Sets the signal sent when input or output  becomes
>          possible.   A  value  of  zero  means  to send the
>          default SIGIO signal.  Any other value  (including
>          SIGIO)  is the signal to send instead, and in this
>          case additional info is available  to  the  signal
>          handler if installed with SA_SIGINFO.
> 
>          Additionally, passing a non-zero value to F_SETSIG
>          changes the signal recipient from a whole  process
>          to  a  specific  thread within a process.  See the
>          desciption of F_SETOWN for more details.
> 
> Does the above seem okay to you?

It looks good, but: 

  1. An omission: It mentions that SIGURG is always sent to the whole
     process.  SIGIO is also sent to the whole process, instead of
     queueing a thread-specific signal, when the signal queue is full.
     Programs that mustn't miss readiness events need to handle it.

  2. The description could be confusing to LinuxThreads users, because
     all the signals are thread-specific in LinuxThreads.


Date: Tue, 12 Apr 2005 16:53:19 +0100
From: Jamie Lokier <jamie@shareable.org>
To: Michael Kerrisk <mtk-manpages@gmx.net>
Subject: Re: Update to fcntl(2) man page

Michael Kerrisk wrote:
> >   1. An omission: It mentions that SIGURG is always sent to the whole
> >      process.  SIGIO is also sent to the whole process, instead of
> >      queueing a thread-specific signal, when the signal queue is full.
> >      Programs that mustn't miss readiness events need to handle it.
> 
> Sorry -- can you point me to the relevant code for the 
> above point please.

In 2.6:

	switch (fown->signum) {
		siginfo_t si;
		default:
			/* Queue a rt signal with the appropriate fd as its
			   value.  We use SI_SIGIO as the source, not 
			   SI_KERNEL, since kernel signals always get 
			   delivered even if we can't queue.  Failure to
			   queue in this case _should_ be reported; we fall
			   back to SIGIO in that case. --sct */
			si.si_signo = fown->signum;
			si.si_errno = 0;
		        si.si_code  = reason;
			/* Make sure we are called with one of the POLL_*
			   reasons, otherwise we could leak kernel stack into
			   userspace.  */
			if ((reason & __SI_MASK) != __SI_POLL)
				BUG();
			if (reason - POLL_IN >= NSIGPOLL)
				si.si_band  = ~0L;
			else
				si.si_band = band_table[reason - POLL_IN];
			si.si_fd    = fd;
			if (!send_sig_info(fown->signum, &si, p))
				break;
		/* fall-through: fall back on the old plain SIGIO signal */
		case 0:
			send_group_sig_info(SIGIO, SEND_SIG_PRIV, p);

2.4 is exactly the same, except:

		/* fall-through: fall back on the old plain SIGIO signal */
		case 0:
			send_sig(SIGIO, p, 1);

The fall-through happens when send_sig_info() fails, which happens
when the real-time signal queue is full.

Programs using a queued signal to track file readiness efficiently (as
an alternative to select/poll), must listen for SIGIO in addition to
the real-time signal, as otherwise they will miss notifications when
the queue is full (which happens often on a busy server).

Multi-threaded programs using NPTL must be aware this SIGIO is
process-wide - so receiving it on one thread must cause all threads to
assume a queued signal may be lost.  Programs using LinuxThreads do
not have to assume this (but it's safe if they do).


Date: Wed, 13 Apr 2005 17:25:44 +0100
From: Jamie Lokier <jamie@shareable.org>
To: Michael Kerrisk <mtk-manpages@gmx.net>
Subject: Re: Update to fcntl(2) man page

Michael Kerrisk wrote:
> I added a few more sentences to the end of that paragraph
> on F_SETOWN:
> 
>     If a non-zero value is given  to  F_SETSIG  in  a multi-threaded
>     process  running with  a threading  library that supports thread
>     groups (e.g., NPTL),  then  a  positive  value  value  given to
>     F_SETOWN has a different meaning: instead  of being a process ID
>     identifying a whole  process, it is a  thread  ID identifying  a
>     specific thread  within a process.  Consequently, it may be nec-
>     essary to pass  F_SETOWN the result of gettid() instead  of  get
>     pid() to  get sensible results  when F_SETSIG is used.  (In cur-
>     rent Linux threading implementations, a main thread's thread  ID
>     is  the  same  as  its  process  ID.   This means that a single-
>     threaded program can equally use gettid() or  getpid()  in  this
>     scenario.)  Note, however, that the statements in this paragraph
>     do not apply to the SIGURG signal generated for out-of-band data
>     on a socket: this signal is always sent to either a process or a
>     process group, depending on the value given to  F_SETOWN.   Note
>     also  that Linux imposes a limit on the number of real-time sig-
>     nals that may be queued to a process (see getrlimit(2) and  sig-
>     nal(7)) and if this limit is reached, then the kernel reverts to
>     delivering SIGIO, and  this  signal is  delivered to the  entire 
>     process rather than to a specifc thread.
> 
> Look oay now?

Looks ood.

It will take a minor genius to translate that to working
multi-threaded RT-SIGIO code without a tutorial -- and in fact I
haven't heard of any program or library which does it (though I'm
trying to write one) -- but technically it seems to include everything.
2005-04-05 05:54:09 +00:00
Michael Kerrisk b6ac53546a Added notes on non-standard behaviour: Linux allows 'buf' to
be NULL, but POSIX.1 doesn't specify this and it's non-portable.
2005-04-04 15:34:13 +00:00
Michael Kerrisk 31830ef083 Noted the PID caching behaviour of NPTL's getpid() wrapper under BUGS. 2005-04-12 08:11:06 +00:00
Michael Kerrisk f2d0bbf129 Added set_thread_area(2), tkill (2) under SEE ALSO 2005-04-11 15:10:47 +00:00
Michael Kerrisk f21a10c814 Noted kernel version where posix_fadvise() appeared and
noted bug in handling of 'len' in kernels < 2.6.6.
2005-04-11 15:04:27 +00:00
Michael Kerrisk 2b44301c2a Added futex(2) and set_tid_address(2) to SEE ALSO 2005-04-11 15:03:38 +00:00
Michael Kerrisk 2f36a80706 Jamie Lokier / mtk
Improved discussion of F_SETOWN and F_SETSIG with respect to
multi-threaded programs.

Generally cleaned up the discussion of F_SETOWN.
2005-04-08 13:42:00 +00:00
Michael Kerrisk c892f4ca9f AEB, Improved descrtiption of read from /dev/urandom 2005-04-08 07:58:55 +00:00
Michael Kerrisk 055fd5fae5 Noted kernel version numbers for semtimedop() 2005-04-08 06:19:20 +00:00
Michael Kerrisk e51d6af5ac "lower-most" --> "lowermost" 2005-04-07 08:00:31 +00:00
Michael Kerrisk fcad9022d3 Matthias Lang, mtk
Noted MAX_SEC_IN_JIFFIES ceiling.
Added note about treatment of out-of-range tv_usec values.
2005-04-06 15:29:32 +00:00
Michael Kerrisk c93df97462 Removed SEE ALSO reference to non-existent newctime(3) 2005-04-06 13:10:34 +00:00
Michael Kerrisk 2a44706019 More clean-up of ERRORS after further communication with Gordon Jin. 2005-04-06 12:59:19 +00:00
Michael Kerrisk 6e01dc7e8d Fixed EINVAL description after mesage from
"Jin, Gordon" <gordon.jin@intel.com>
2005-04-05 17:01:47 +00:00
Michael Kerrisk 7257eeb80e Added description of strcasestr(). 2005-04-05 14:01:07 +00:00
Michael Kerrisk bbcdba9c19 Link to strstr.3 2005-04-05 14:00:36 +00:00
Michael Kerrisk e8de013ac1 More changes from Marko Kohtala <marko.kohtala@gmail.com> 2005-04-05 12:49:00 +00:00
Michael Kerrisk e2af0daf4a Updates from Kai Makisara <Kai.Makisara@kolumbus.fi>, the author
of the st driver.
2005-04-05 12:20:49 +00:00
Michael Kerrisk b6dd43ba57 Heikki Orsila <shd@modeemi.cs.tut.fi>:
bcopy handles overlapping case, but memcpy does not,
so for consistency memmove should be also mentioned.
2005-04-04 17:03:48 +00:00
Michael Kerrisk 490df3ae03 Noted discrepancy between Linux and POSIX.1 when oldpath is a symbolic
link.
2005-04-04 16:54:25 +00:00
Michael Kerrisk 3d9a2200a6 Improved various error descriptions after message from
Marko Kohtala <marko.kohtala@gmail.com>.
2005-04-04 16:33:48 +00:00
Michael Kerrisk 2d5d4b0dd0 Clarified description of EXDEV error with respect to
file system mounted at multiple points, as per rename.2
patch from Michael Haardt <michael@moria.de>.
2005-04-04 14:14:02 +00:00
Michael Kerrisk 1dba3c20aa Patch from AEB: improved DESCRIPTION; clarified distinction between
EACCES and ENOEXEC.
2005-04-04 13:10:49 +00:00
Michael Kerrisk dd1b9170eb mention the .URL macro more verbosely, as per patch from
Martin Schulze <joey@infodrom.org>
Branden Robinson <branden@debian.org> 
Colin Watson <cjwatson@debian.org>
2005-04-04 12:59:48 +00:00
Michael Kerrisk b4ab6f83e1 "may not" --> "should not", after suggestion from
Sasa Stevanovic <mg94c18@alas.matf.bg.ac.yu>
2005-04-04 09:27:23 +00:00
Michael Kerrisk 9fe9d301af mmap() improvements from Martin Pool 2005-03-31 14:42:09 +00:00
Michael Kerrisk 042d7c1b37 Added sigqueue(2) to SEE ALSO 2005-03-31 14:27:35 +00:00
Michael Kerrisk d5d202ca89 Link to man3/getmntent.3 2005-03-31 14:17:46 +00:00
Michael Kerrisk e17d909d2b Typo fix: s/joey@infodeom.org/joey@infodrom.org/ 2005-03-31 14:12:28 +00:00
Michael Kerrisk c1f2160361 Removed SVr2, AT&T, and BSD from CONFORMING TO, since
a pipe on those systems is actually bidirectional
(Pipes are implemented as STREAMS on the former, and
sockets on the latter.)
2005-03-31 14:08:14 +00:00
Michael Kerrisk c5a2d222f8 Added EINTR error 2005-03-31 13:41:40 +00:00
Michael Kerrisk 7f564f717e Noted that SUSv2 allowed a range of 00 to 61 for %S specifier. 2005-03-31 13:22:34 +00:00
Michael Kerrisk b7d1c64591 Fixed typo as per msg from Michael Mühlebach <michael@anduin.ch> 2005-03-31 12:59:18 +00:00
Michael Kerrisk 9651df7566 Moved 2.01 changes into this file 2005-03-31 12:57:55 +00:00
Michael Kerrisk c42f7ee8da Initial changes for 2.02 release 2005-03-31 12:42:38 +00:00
Michael Kerrisk fb1719bd32 renamed for 2.02 release 2005-03-31 12:41:12 +00:00
Michael Kerrisk 972a9aee95 2004-12-20 14:09:40 +00:00
Michael Kerrisk 3f537e8a54 x 2004-12-20 14:04:51 +00:00
Michael Kerrisk 8411b25e54 2004-12-20 14:02:17 +00:00
Michael Kerrisk 0680aa5b8a 2004-12-20 14:00:28 +00:00
Michael Kerrisk 3047394a62 Tony Crawford
As per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=270817
Formulae on the pages should be T = S / C not T = C / S.
2004-12-20 13:43:09 +00:00
Michael Kerrisk dc23fde14f Pedro Zorzenon
as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=242638
    Noted use of _XOPEN_SOURCE to get macros <sytdlib.h>
    as for wait(2).

mtk
    Changed name of argument from 'string' to 'command' (like POSIX).

    Noted that glibc does nowadays explicitly check for the existence
    of the shell if 'command' is NULL, rather than the older behaviour
    of assuming the shell exists and always returning 1 if
    'command' is NULL.

    Other wording and formatting clean-ups.
2004-12-20 13:24:38 +00:00
Michael Kerrisk cca657e227 triggered by http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=283179
The wording describing how errno is set was tidied up in a number of
pages.
2004-12-20 12:24:06 +00:00
Michael Kerrisk 0c00f46ce7 Cartsen Hey
as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=276248

    Changed range for "%S" from 0..61 to 0..60.

    SUSv3 says 0..60.  I think the manual page probably says
    0..61, because that's what SUSv2 said.
    (Some other implementations' man pages also say 0..61 --
    e.g., Solaris 8 & 9, Tru64 5.1B; FreeBSD 5.1 says 0..60.)

    The glibc manual currently says 0..60.

    Given that SUSv3 says 0..60, I've changed this the
    manual page to also say this:

        -The second as a decimal number (range 00 to 61).
        +The second as a decimal number (range 00 to 60).
        +(The range is up to 60 to allow for occasional leap seconds.)
2004-12-20 11:22:11 +00:00
Michael Kerrisk d536842d52 Marek Habersack <grendel@debian.org>
.SH "CONFORMING TO"
-BSD 4.4
+BSD 4.4, SUSv3
as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=234443
2004-12-20 10:54:45 +00:00
Michael Kerrisk d3018c3c5e "from a socket" --> "on a socket" 2004-12-20 10:53:41 +00:00
Michael Kerrisk 50a0922f20 Johannes Berg / http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=226974
-.BR POSIX2_FORT_RUN " - " _SC_2_FORT_DEV
        +.BR POSIX2_FORT_DEV " - " _SC_2_FORT_DEV<F2>
2004-12-20 10:45:56 +00:00
Michael Kerrisk a2ef1094f4 Fix typo as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=224953
Changed erroneous "aio_return(2)" to "aio_return(3)"
2004-12-20 10:14:48 +00:00