~ubuntu-branches/ubuntu/saucy/manpages/saucy

« back to all changes in this revision

Viewing changes to man2/fcntl.2

  • Committer: Bazaar Package Importer
  • Author(s): Joey Schulze
  • Date: 2010-03-02 21:49:58 UTC
  • mfrom: (1.1.42 upstream) (2.2.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100302214958-69yjgb70t7wrjo3m
New upstream version
. Remove crufty statement in setuid(2) that seteuid() is not in POSIX
(closes: Bug#569812)
. Fix description of 'nochdir' argument in daemon(3) (closes: Bug#554819)
. Fix NAME line in path_resolution(7) (closes: Bug#558300)

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
.\" 2005-05-20, Johannes Nicolai <johannes.nicolai@hpi.uni-potsdam.de>,
53
53
.\"     mtk: Noted F_SETOWN bug for socket file descriptor in Linux 2.4
54
54
.\"     and earlier.  Added text on permissions required to send signal.
 
55
.\" 2009-09-30, Michael Kerrisk
 
56
.\"     Note obsolete F_SETOWN behavior with threads.
 
57
.\"     Document F_SETOWN_EX and F_GETOWN_EX
55
58
.\"
56
 
.TH FCNTL 2 2009-07-25 "Linux" "Linux Programmer's Manual"
 
59
.TH FCNTL 2 2009-10-17 "Linux" "Linux Programmer's Manual"
57
60
.SH NAME
58
61
fcntl \- manipulate file descriptor
59
62
.SH SYNOPSIS
428
431
The Linux implementation of mandatory locking is unreliable.
429
432
See BUGS below.
430
433
.SS "Managing signals"
431
 
.BR F_GETOWN ", " F_SETOWN ", " F_GETSIG " and " F_SETSIG
 
434
.BR F_GETOWN ,
 
435
.BR F_SETOWN ,
 
436
.BR F_GETOWN_EX ,
 
437
.BR F_SETOWN_EX ,
 
438
.BR F_GETSIG
 
439
and
 
440
.B F_SETSIG
432
441
are used to manage I/O availability signals:
433
442
.TP
434
443
.BR F_GETOWN " (\fIvoid\fP)"
510
519
.\" refers to a terminal device, then SIGIO
511
520
.\" signals are sent to the foreground process group of the terminal.
512
521
 
513
 
If a non-zero value is given to
 
522
The following was true in 2.6.x kernels up to and including
 
523
kernel 2.6.11:
 
524
.RS
 
525
.IP
 
526
If a nonzero value is given to
514
527
.B F_SETSIG
515
528
in a multithreaded process running with a threading library
516
529
that supports thread groups (e.g., NPTL),
548
561
.\" kill_fasync()/send_sigio()/send_sigio_to_task()
549
562
.\" to directly call send_group_sig_info()
550
563
.\"     -- MTK, Apr 2005 (kernel 2.6.11)
551
 
Note also that Linux imposes a limit on the
552
 
number of real-time signals that may be queued to a
553
 
process (see
554
 
.BR getrlimit (2)
 
564
.RE
 
565
.IP
 
566
The above behavior was accidentally dropped in Linux 2.6.12,
 
567
and won't be restored.
 
568
From Linux 2.6.32 onwards, use
 
569
.BR F_SETOWN_EX
 
570
to target
 
571
.B SIGIO
555
572
and
556
 
.BR signal (7))
557
 
and if this limit is reached, then the kernel reverts to
558
 
delivering
559
 
.BR SIGIO ,
560
 
and this signal is delivered to the entire
561
 
process rather than to a specific thread.
562
 
.\" See fs/fcntl.c::send_sigio_to_task() (2.4/2.6) sources -- MTK, Apr 05
 
573
.B SIGURG
 
574
signals at a particular thread.
 
575
.TP
 
576
.BR F_GETOWN_EX " (struct f_owner_ex *) (since Linux 2.6.32)"
 
577
Return the current file descriptor owner settings
 
578
as defined by a previous
 
579
.BR F_SETOWN_EX
 
580
operation.
 
581
The information is returned in the structure pointed to by
 
582
.IR arg ,
 
583
which has the following form:
 
584
.nf
 
585
.in +4n
 
586
 
 
587
struct f_owner_ex {
 
588
    int   type;
 
589
    pid_t pid;
 
590
};
 
591
 
 
592
.in
 
593
.fi
 
594
The
 
595
.I type
 
596
field will have one of the values
 
597
.BR F_OWNER_TID ,
 
598
.BR F_OWNER_PID ,
 
599
or
 
600
.BR F_OWNER_PGRP .
 
601
The
 
602
.I pid
 
603
field is a positive integer representing a thread ID, process ID,
 
604
or process group ID.
 
605
See
 
606
.B F_SETOWN_EX
 
607
for more details.
 
608
.TP
 
609
.BR F_SETOWN_EX " (struct f_owner_ex *) (since Linux 2.6.32)"
 
610
This operation performs a similar task to
 
611
.BR F_SETOWN .
 
612
It allows the caller to direct I/O availability signals
 
613
to a specific thread, process, or process group.
 
614
The caller specifies the target of signals via
 
615
.IR arg ,
 
616
which is a pointer to a
 
617
.IR f_owner_ex
 
618
structure.
 
619
The
 
620
.I type
 
621
field has one of the following values, which define how
 
622
.I pid
 
623
is interpreted:
 
624
.RS
 
625
.TP
 
626
.BR F_OWNER_TID
 
627
Send the signal to the thread whose thread ID
 
628
(the value returned by a call to
 
629
.BR clone (2)
 
630
or
 
631
.BR gettid (2))
 
632
is specified in
 
633
.IR pid .
 
634
.TP
 
635
.BR F_OWNER_PID
 
636
Send the signal to the process whose ID
 
637
is specified in
 
638
.IR pid .
 
639
.TP
 
640
.BR F_OWNER_PGRP
 
641
Send the signal to the process group whose ID
 
642
is specified in
 
643
.IR pid .
 
644
(Note that, unlike with
 
645
.BR F_SETOWN ,
 
646
a process group ID is specified as a positive value here.)
 
647
.RE
563
648
.TP
564
649
.BR F_GETSIG " (\fIvoid\fP)"
565
650
Return (as the function result)
588
673
is the signal to send instead, and in this case additional info
589
674
is available to the signal handler if installed with
590
675
.BR SA_SIGINFO .
591
 
 
592
 
Additionally, passing a non-zero value to
593
 
.B F_SETSIG
594
 
changes the signal recipient from a whole process to a specific thread
595
 
within a process.
596
 
See the description of
597
 
.B F_SETOWN
598
 
for more details.
 
676
.\"
 
677
.\" The following was true only up until 2.6.11:
 
678
.\"
 
679
.\" Additionally, passing a nonzero value to
 
680
.\" .B F_SETSIG
 
681
.\" changes the signal recipient from a whole process to a specific thread
 
682
.\" within a process.
 
683
.\" See the description of
 
684
.\" .B F_SETOWN
 
685
.\" for more details.
599
686
 
600
687
By using
601
688
.B F_SETSIG
602
 
with a non-zero value, and setting
 
689
with a nonzero value, and setting
603
690
.B SA_SIGINFO
604
691
for the
605
692
signal handler (see
633
720
if
634
721
.B SA_SIGINFO
635
722
is set for the signal handler, as above.
 
723
 
 
724
Note that Linux imposes a limit on the
 
725
number of real-time signals that may be queued to a
 
726
process (see
 
727
.BR getrlimit (2)
 
728
and
 
729
.BR signal (7))
 
730
and if this limit is reached, then the kernel reverts to
 
731
delivering
 
732
.BR SIGIO ,
 
733
and this signal is delivered to the entire
 
734
process rather than to a specific thread.
 
735
.\" See fs/fcntl.c::send_sigio_to_task() (2.4/2.6) sources -- MTK, Apr 05
636
736
.PP
637
737
Using these mechanisms, a program can implement fully asynchronous I/O
638
738
without using
646
746
.BR F_GETOWN ,
647
747
.B F_SETOWN
648
748
is specific to BSD and Linux.
649
 
.B F_GETSIG
 
749
.BR F_GETOWN_EX ,
 
750
.BR F_SETOWN_EX ,
 
751
.BR F_GETSIG ,
650
752
and
651
753
.B F_SETSIG
652
754
are Linux-specific.
846
948
feature test macro must be defined.)
847
949
 
848
950
Directory notifications are normally "one-shot", and the application
849
 
must re-register to receive further notifications.
 
951
must reregister to receive further notifications.
850
952
Alternatively, if
851
953
.B DN_MULTISHOT
852
954
is included in
1007
1109
.B F_DUPFD_CLOEXEC
1008
1110
is specified in POSIX.1-2008.
1009
1111
 
 
1112
.BR F_GETOWN_EX ,
 
1113
.BR F_SETOWN_EX ,
1010
1114
.BR F_GETSIG ,
1011
1115
.BR F_SETSIG ,
1012
1116
.BR F_NOTIFY ,
1054
1158
will be \-1, and
1055
1159
.I errno
1056
1160
will contain the (positive) process group ID.
 
1161
The Linux-specific
 
1162
.BR F_SETOWN_EX
 
1163
and
 
1164
.BR F_GETOWN_EX
 
1165
operations avoid this problem.
1057
1166
.\" mtk, Dec 04: some limited testing on alpha and ia64 seems to
1058
1167
.\" indicate that ANY negative PGID value will cause F_GETOWN
1059
1168
.\" to misinterpret the return as an error. Some other architectures
1113
1222
is called
1114
1223
.IR mandatory.txt .)
1115
1224
.SH COLOPHON
1116
 
This page is part of release 3.23 of the Linux
 
1225
This page is part of release 3.24 of the Linux
1117
1226
.I man-pages
1118
1227
project.
1119
1228
A description of the project,