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
56
.TH FCNTL 2 2009-07-25 "Linux" "Linux Programmer's Manual"
59
.TH FCNTL 2 2009-10-17 "Linux" "Linux Programmer's Manual"
58
61
fcntl \- manipulate file descriptor
428
431
The Linux implementation of mandatory locking is unreliable.
430
433
.SS "Managing signals"
431
.BR F_GETOWN ", " F_SETOWN ", " F_GETSIG " and " F_SETSIG
432
441
are used to manage I/O availability signals:
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.
513
If a non-zero value is given to
522
The following was true in 2.6.x kernels up to and including
526
If a nonzero value is given to
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
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
557
and if this limit is reached, then the kernel reverts to
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
574
signals at a particular thread.
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
581
The information is returned in the structure pointed to by
583
which has the following form:
596
field will have one of the values
603
field is a positive integer representing a thread ID, process ID,
609
.BR F_SETOWN_EX " (struct f_owner_ex *) (since Linux 2.6.32)"
610
This operation performs a similar task to
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
616
which is a pointer to a
621
field has one of the following values, which define how
627
Send the signal to the thread whose thread ID
628
(the value returned by a call to
636
Send the signal to the process whose ID
641
Send the signal to the process group whose ID
644
(Note that, unlike with
646
a process group ID is specified as a positive value here.)
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
592
Additionally, passing a non-zero value to
594
changes the signal recipient from a whole process to a specific thread
596
See the description of
677
.\" The following was true only up until 2.6.11:
679
.\" Additionally, passing a nonzero value to
681
.\" changes the signal recipient from a whole process to a specific thread
682
.\" within a process.
683
.\" See the description of
685
.\" for more details.
602
with a non-zero value, and setting
689
with a nonzero value, and setting
605
692
signal handler (see
635
722
is set for the signal handler, as above.
724
Note that Linux imposes a limit on the
725
number of real-time signals that may be queued to a
730
and if this limit is reached, then the kernel reverts to
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
637
737
Using these mechanisms, a program can implement fully asynchronous I/O
846
948
feature test macro must be defined.)
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
1054
1158
will be \-1, and
1056
1160
will contain the (positive) process group ID.
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