summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/forkfd
Commit message (Collapse)AuthorAgeFilesLines
* forkfd_linux: change childStack size from 4096 to SIGSTKSZHuang Rui2023-10-251-1/+1
| | | | | | | | | | | | | | Starting from qt-6.6.0, the childStack size has been too small to run qmake or qsb in the sandbox, which will cause segfault. This problem can be fixed by changing the childStack size to SIGSTKSZ. For security reasons, some Linux distributions, such as gentoo, will use the sandbox when building applications. Previously, qt-6.5.0 could be successfully built in the sandbox. The problem started with qt-6.6.0. See also: https://bugs.gentoo.org/915695 Pick-to: 6.6 Change-Id: I229c25397f557dd2fec3e0ec53ac68fda28bab13 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* forkfd: Add support for eventfd(2) in FreeBSDThiago Macieira2023-06-071-8/+8
| | | | | | | | Drive-by make the code slightly nicer. Change-Id: Idd5e1bb52be047d7b4fffffd174db9162cf697a4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Split multi-file Files entries in qt_attribution.json as listsEdward Welbourne2023-04-201-1/+1
| | | | | | | | | | | This is now the official format for Files, when there's more than one, rather than using space-joined lists. Pick-to: 6.5 Change-Id: I4a6247fff0ece8ece2944178af38894fd5a2e1e2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Deploy Comment fields in qt_attribution.json filesEdward Welbourne2023-04-201-1/+1
| | | | | | | | | | | | | | Replace the old abuse of other fields as comments, to be overwritten by a later setting to a proper value, with actual Comment fields, now that we have them. Added a new comment to the valgrind files to say where they come from in the upstream. Pick-to: 6.5 Change-Id: I2edcfa2949fa9e59f3f67d3e578d8e5009854cf6 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* forkfd/linux: add support for LoongArchWANG Xuerui2022-11-251-1/+2
| | | | | | | | | | This architecture is not CLONE_BACKWARDS in any way. Matching OpenDCDiag PR: https://github.com/opendcdiag/opendcdiag/pull/169 Pick-to: 6.4 6.2 5.15 Change-Id: Ibceccfd20d270b30302a936885d12e4c55cdd833 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* forkfd: fix Clang 15 ATOMIC_VAR_INIT deprecation warningMarc Mutz2022-10-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Replace the macro use with the expansion of the macro as it appears in both libc++ as well as libstdc++. Fixes Clang 15 C++20 warning-turned-error: forkfd.c:157:39: error: macro 'ATOMIC_VAR_INIT' has been marked as deprecated [-Werror,-Wdeprecated-pragma] static ffd_atomic_int forkfd_status = FFD_ATOMIC_INIT(0); ^ forkfd_c11.h:51:37: note: expanded from macro 'FFD_ATOMIC_INIT' #define FFD_ATOMIC_INIT(val) ATOMIC_VAR_INIT(val) ^ /d/llvm/15/bin/../include/c++/v1/atomic:2671:43: note: macro marked 'deprecated' here # pragma clang deprecated(ATOMIC_VAR_INIT) ^ Matching OpenDCDiag pull request: https://github.com/opendcdiag/opendcdiag/pull/159 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I0204f7fcd6039624ed75d414daf9b6a771bfd9d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* forkfd: implement vfork(2)-like support on LinuxThiago Macieira2022-07-164-60/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fork() works by implementing Copy-On-Write for all pages that either the parent or the child process write to. So if the parent process continues running while the child is between fork(2) and execve(2), then it will keep causing page faults and requiring the OS to duplicate those pages, which may be expensive (page table updates, TLB flushes, etc.). This problem is aggravated if the parent process is multithreaded, as the simple act of running in the parent will cause those threads' stacks to cause page faults. The BSD solution for that was vfork(), which has two differences in behavior: (1) it blocks the parent from running and (2) it shares memory with it. But it's always been tricky, so POSIX.1-2001 deprecated it and 2008 removed its definition completely. Still, it is available somewhat widely, and on Linux that can be achieved with clone(2) and the CLONE_VFORK and CLONE_VM flags, for those two behaviors respectively. Because of (2), we can't return from the forkfd() function in the child (as that would trash the stack in the parent process), so to implement this functionality vforkfd() adds a callback of the same signature as glibc's clone(2) wrapper (something that hadn't occurred to me when we attempted to use CLONE_VFORK last time). On Linux, (1) is no problem, as clone(2) has native forkfd support. But on other OSes, forkfd() requires the parent to run before the child execve()s, in order to save the child PID in the list of children we're going to handle SIGCHLD for in a non-racy way. Investigating if it is possible to use vfork() anyway is left as an exercise for the reader. Matching OpenDCDiag pull request: https://github.com/opendcdiag/opendcdiag/pull/94 Pick-to: 6.4 Fixes: QTBUG-104493 Change-Id: Id0fb9ab0089845ee8843fffd16fa63c7c6f7dd1c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* forkfd: don't attempt to guess EWOULDBLOCK when WNOHANG is activeThiago Macieira2022-03-081-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Reading the kernel sources, I was sure we'd get an ECHILD if the child hadn't exited yet, but that's not the case. We only get ECHILD if the current process has no child processes. But if we do have one and the one we're waiting for hasn't exited, waitid() returns 0. So let's not attempt to correct it with forkfd_wait() or forkfd_wait4(). Those have "wait" in the name, so they should behave exactly the same way. The man pages say: waitpid(): if WNOHANG was specified and one or more child(ren) specified by pid exist, but have not yet changed state, then 0 is returned. waitid(): returns 0 on success or if WNOHANG was specified and no child(ren) specified by id has yet changed state This was found while studying QTBUG-100174. QProcess does not use this code path (blocking mode forkfd only). Matching OpenDCDiag PR: https://github.com/opendcdiag/opendcdiag/pull/62 Pick-to: 6.2 6.3 Change-Id: Ibf4acec0f166495998f7fffd16d6de6853a6e5a8 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* forkfd: sync with OpenDCDiagThiago Macieira2022-03-081-1/+1
| | | | | | | | Matches https://github.com/opendcdiag/opendcdiag/blob/0cd579d973cb80da179481addfed9d9d985f67d5/framework/forkfd/forkfd.c Change-Id: Ibf4acec0f166495998f7fffd16d6deb90aa05668 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* forkfd/Linux: ask clone() to use the SIGCHLD as the termination signalThiago Macieira2020-09-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because of these lines in the Linux kernel (kernel/fork.c, see [1][3]): if (clone_flags & CLONE_VFORK) trace = PTRACE_EVENT_VFORK; else if (args->exit_signal != SIGCHLD) trace = PTRACE_EVENT_CLONE; else trace = PTRACE_EVENT_FORK; Without CLONE_VFORK (which we can't use), if the exit signal isn't SIGCHLD, the debugger will get a PTRACE_EVENT_CLONE, which makes it think the process we're starting is a thread, not a new process. Both gdb and lldb remain attached to the child and when it later performs an execve(), they get mightily confused. See gdb bug report[5]. The idea of not having an exit_signal was so that no SIGCHLD would be delivered to the parent process in the first place. That way, some misguided SIGCHLD handler (*cough* GLib *cough*) wouldn't reap our processes. Unfortunately, what I didn't realize was that the kernel sends SIGCHLD anyway (see [2][4]), so this defensive measure didn't actually work. Consequently, we can pass SIGCHLD to clone() and get the debuggers working again. [ChangeLog][Linux] Fixed an issue that would cause debugging a Qt application that uses QProcess to confuse both gdb and lldb if the Linux kernel was version 5.4 or higher. Behavior outside of a debugging session was not affected. [1] https://code.woboq.org/linux/linux/kernel/fork.c.html#_do_fork [2] https://code.woboq.org/linux/linux/kernel/signal.c.html#do_notify_parent [3] https://elixir.bootlin.com/linux/v5.8/source/kernel/fork.c#L2432 [4] https://elixir.bootlin.com/linux/v5.8/source/kernel/signal.c#L1925 [5] https://sourceware.org/bugzilla/show_bug.cgi?id=26562 Fixes: QTBUG-86319 Pick-to: 5.15 Change-Id: I2fc68c725ba649218bd9fffd1633863613537d42 Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: hjk <hjk@qt.io>
* forkfd: remove FFD_VFORK_SEMANTICSThiago Macieira2020-06-303-9/+0
| | | | | | | | | | | | | | | This will never work, not unless libc implements it themselves, since the child process is not allowed to return from the function that does the vfork(), as subsequent use of the stack would trash the frozen parent's return address, and in our case that's syscall(). Instead, we may add a vforkfd() function that takes a callback function that will be called in that context, like the glibc clone(3) wrapper does. Pick-to: 5.15 Change-Id: I1dba29bc0f454df09ca1fffd161800b453c00593 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* forkfd/linux: add support for RISC-VAndreas Schwab2020-06-231-1/+1
| | | | | | Pick-to: 5.15 Change-Id: I758a401abd6851839908e09aec51edbe4aa95925 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* forkfd/linux: handle failure from sys_cloneAndreas Schwab2020-06-231-0/+2
| | | | | | Pick-to: 5.15 Change-Id: I98a28a816fdc089cefcbf8f42053ddffedc10cdf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Suppress warning of unused function on macOSThiago Macieira2020-06-121-0/+3
| | | | | | | | | | This function is only used on FreeBSD and Linux. forkfd.c:243:12: warning: unused function 'convertForkfdWaitFlagsToWaitFlags' [-Wunused-function] Pick-To: 5.15 Change-Id: I99ab0f318b1c43b89888fffd160bf81f01960f2f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* forkfd: add FFD_VFORK_SEMANTICS flagThiago Macieira2020-03-253-5/+15
| | | | | | | | | | | | | | | | | | | | This flag asks forkfd() to use vfork semantics wherever available. That is, suspend the calling process execution until the child either does an execve(2) or _exit(2). The advantage of that is that it puts lower pressure on the OS VMM system, as the number of pages that need to be copy-on-write duplicated is much smaller (still not zero, as at least the stack in the child will be written to). However, the only implementation that supports using this flag for now is Linux's pidfd. It would be possible to add to FreeBSD, but pdfork(2) does not have a flag for this behavior -- if it gets one, we can add support for it later. Everywhere else, we need to force the child to not exit until we store the child process's PID in the ProcessInfo structure we allocated, which means the parent process must run before we even return from forkfd(). Change-Id: I1bee3bc466a04f19bd6efffd15f447f28c201aa9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* forkfd: fix forkfd_wait when FFD_USE_FORK was activeThiago Macieira2020-03-251-3/+25
| | | | | | | | | | | | | | | | If we detected that the OS supports a version of system forkfd (Linux pidfd, FreeBSD procdesc), the forkfd_wait() function was using only the system waiting implementation, which of course can't work for file descriptors created with FFD_USE_FORK. So just detect EBADF and attempt again. If the file descriptor is neither one of our pipes nor a system forkfd, bad things will happen... Fixes: QTBUG-82351 Change-Id: I4e559af2a9a1455ab770fffd15f59fb3160b22eb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* forkfd: introduce forkfd_wait4() that takes optionsThiago Macieira2020-03-254-22/+56
| | | | | | | | | | | | | | | | | | "wait4" because it looks like the wait4() BSD function, which has the signature: pid_t wait4(pid_t pid, int *wstatus, int options, struct rusage *rusage); And because ours also has 4 parameters. Having options is important anyway. I might want to add some more later, but we can't really support them with the fall back implementation (in fact, we don't honor WNOHANG in the fall back implementation either). Change-Id: I4e559af2a9a1455ab770fffd15f5858bb357e15b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* forkfd: add FFD_USE_FORK to force use of fork()Thiago Macieira2020-01-092-5/+14
| | | | | Change-Id: Ia2aa807ffa8a4c798425fffd15d933e47919247a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* forkfd/Linux: remove unused codeThiago Macieira2020-01-091-68/+0
| | | | | | | | | The detection code for Linux 5.2 and 5.3 went unused. We had it in the initial commit so it got recorded for posterity, in case someone wants to detect them (the road not taken). Change-Id: Ib5d667bf77a740c28d2efffd15cccdff5aa5a622 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* forkfd: Implement forkfd in terms of Linux 5.2's CLONE_PIDFDThiago Macieira2020-01-092-0/+253
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux 5.2 added the CLONE_PIDFD flag to the clone(2) system call. Linux 5.3 also added the clone3(2) system call, which allows both CLONE_PIDFD and CLONE_PARENT_SETTID, which we could use but don't really need. Unfortunately, 5.2 missed one crucial and one convenient change. Without the P_PIDFD support in waitid(2), we would need to either remember the PID of the child process or obtain it from /proc. But without support for polling on pidfds, we can't find out when the child process exited. Support for the latter was added in 5.3, which would be sufficient for us, but it's not easy to detect it at runtime. The support is also being backported to Android's 4.9 kernel[1], so we can't do version checks, only functionality. This commit relies on waitid(2) support, which was the last to be added and is fortunately the easiest to detect. If it's present, we assume the whole series is present and use pidfds. [1] https://android-review.googlesource.com/q/topic:%22pidfd+polling+support+4.9+backport%22 See-Also: https://lkml.org/lkml/2015/3/12/1044 (original idea) See-Also: https://lkml.org/lkml/2019/4/19/441 (CLONE_PIDFD) See-Also: https://lkml.org/lkml/2019/4/25/884 (poll(2) support) See-Also: https://lkml.org/lkml/2019/7/27/334 (P_PIDFD) Change-Id: Ia0aac2f09e9245339951ffff13c94b3aa13d8b63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* forkfd: fix build with GCC 4.8 & 4.9Thiago Macieira2019-12-191-1/+1
| | | | | | | | | | | | | Prior to GCC 5.x, std::atomic_int was a typedef to __atomic_base<int>, which meant we couldn't use it in atomic_compare_exchange that requires pointers to std::atomic<int>. That changed in 5.x (r219790) in response to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940. Easy fix, though. Fixes: QTBUG-80896 Change-Id: I46bf1f65e8db46afbde5fffd15e1d625154f8d59 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* forkfd: move the FreeBSD system implementation to a separate fileThiago Macieira2019-08-202-109/+170
| | | | | | | | Simplifies the code a bit and will be helpful when I add the Linux equivalent. Change-Id: Iec9c051acd73484c8d94fffd15b99879dc269db9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* forkfd: Add C11 and C++11 atomic supportThiago Macieira2019-08-203-3/+104
| | | | | | | | | | | For forkfd, this is extremely useful, since users can rely on proper atomic API, not the old GCC API or the internal API that backs the C11 / C++11 implementation itself. This also caught one more mistaken use of seq_cst. Change-Id: Iec9c051acd73484c8d94fffd15b9985fe545e8b5 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* forkfd: fix compilation in C mode without precompiled headersThiago Macieira2019-08-202-4/+5
| | | | | | | | | Missing one "struct" and one #include <sys/wait.h> for struct rusage. Change-Id: Iec9c051acd73484c8d94fffd15b9a1274703afca Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Port from implicit to explicit atomic pointer operationsMarc Mutz2019-06-291-2/+2
| | | | | | | | | | | | The old code used the implicit conversions from QAtomicPointer<T> to T* and vice versa. The semantics of these differ from the ones std::atomic uses, so we're going to deprecate these, like we did for load() and store(), too. This patch fixex some users of these APIs before we deprecate them. Change-Id: I0a88bb1c359392538bb64b511bfc62381a56a468 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from implicit to explicit atomic integer operationsMarc Mutz2019-06-281-1/+1
| | | | | | | | | | | | The old code used the implicit conversions from QAtomicInteger<T> to T and vice versa. The semantics of these differ from the ones std::atomic uses, so we're going to deprecate these, like we did for load() and store(), too. This patch fixex some users of these APIs before we deprecate them. Change-Id: I4877276581757cd57e042efea8296fe535a493d1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update various qt_attribution.json filesEdward Welbourne2018-11-021-0/+2
| | | | | | | | | | | | | Marking various as final because no upstream is known or available. Listing versions of others, where I was able to discover them. Updated a stale link (that helpfully redirected). Task-number: QTBUG-70008 Change-Id: Id00f34827133c560735c68793b4f1353f2b2ca85 Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* forkfd: Restore errno on exit from the SIGCHLD handlerThiago Macieira2018-05-301-40/+45
| | | | | | | | | | | | | | | I'd never thought about it, but it is a requirement: a signal handler must leave the global state as it found it (except for those bits that it intended to change, and those must be done in an async-signal-safe way). Otherwise, errno could change from one line to the next in the middle of some code. [ChangeLog][QtCore][QProcess] On Unix, the QProcess SIGCHLD handler now restores errno on exit. Task-number: QTBUG-68472 Change-Id: If025d476890745368955fffd1531e7126f1436d9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* Bump minimum glibc requirement for sys/eventfd.h to glibc 2.8Thiago Macieira2017-08-041-2/+4
| | | | | | | | | | | | | | | The file was added to glibc 2.7 along with the functions we need (Added 2007-10-05). But they forgot to install the file until a month and a half later (2007-11-17), which means it missed the 2.7 release (2007-10-19). Note that EFD_CLOEXEC wasn't added until glibc 2.9, so effectively glibc 2.9 is required. Change-Id: I3868166e5efc45538544fffd14d773ba576fb793 Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* forkfd: fix calling the old signal handler when there wasn't oneThiago Macieira2017-03-061-4/+6
| | | | | | | | | | | | On some stupid systems, execve() may clear the handler but not clear the SA_SIGINFO flag. This change now requires that sa_handler and sa_sigaction be in a union together. We can't operate otherwise. Task-number: QTBUG-59246 Change-Id: I33850dcdb2ce4a47878efffd14a84b48a8f6b1e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* forkfd: use SA_SIGINFO to pass extra information to chained handlersThiago Macieira2017-02-261-11/+15
| | | | | | | | | | This existed in QProcess before forkfd, but was lost in the port to it (commit 1814142b7a11befab315bf3f9d91c4ffbf56ef3e). The original QProcess fix was done in 97279d05822a70da1fb3dab083d823a5f5a008fe. Task-number: QTBUG-57584 Change-Id: Ibc5c715fda334a75bd2efffd14a425871f3162b5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix forkfd 3rd party documenationKai Koehne2016-11-232-1/+2
| | | | | | | | | | Bring the copyright lines in the license and the one's in the metadata into line by using the ones from forkfd.c. Also bring back description of forkfd from 5.6 documentation. Change-Id: I423ee8d5d1e1c866a34c346f78520d33ea099b5e Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Avoid clang warnings about unused return valuesLars Knoll2016-11-091-2/+2
| | | | | Change-Id: Iebec7fb425a92199592cb3ea92190dd0bb5deabd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add qt_attribution.json filesKai Koehne2016-08-122-0/+31
| | | | | | | | | | | | | | The format is documented in http://wiki.qt.io/Qt_attribution.json Also add a LICENSE file in case there is none yet (usually copied from the source headers). Task-number: QTBUG-55139 Change-Id: Ib54c73d0bb9946cfd8579e86c6858035184ca516 Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-06-061-3/+43
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf config.tests/unix/nis/nis.cpp mkspecs/unsupported/freebsd-g++/qplatformdefs.h src/corelib/tools/qdatetime.cpp src/corelib/tools/qsimd.cpp src/corelib/tools/qsimd_p.h src/network/access/access.pri src/network/access/qnetworkreplynsurlconnectionimpl.mm src/network/access/qnetworkreplynsurlconnectionimpl_p.h src/plugins/platforms/cocoa/qnsview.mm src/plugins/printsupport/windows/qwindowsprintdevice.cpp tests/auto/corelib/kernel/qobject/tst_qobject.cpp tests/auto/network/access/qnetworkreply/BLACKLIST tests/auto/widgets/widgets/qopenglwidget/BLACKLIST Change-Id: I4b32055bbf922392ef0264fd403405416fffee57
| * NetBSD/OpenBSD: Compile fix and proper detection of pipe2Ralf Nolden2016-06-041-1/+6
| | | | | | | | | | | | | | | | | | | | Add the necessary defines for HAVE_PIPE2 for NetBSD and OpenBSD depending on OS version when pipe2(2) was added. This also fixes the compile error on NetBSD if -Werror=unused-function for ignore_sigpipe() as the HAVE_PIPE2 tree is prior to O_NOSIGPIPE in create_pipe(). Change-Id: Ic8f875e34ef826a7bf046c77588afecaa097deca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * forkfd: Make sure we handle SIGPIPE tooThiago Macieira2016-05-231-2/+37
| | | | | | | | | | | | | | | | | | | | We can't depend on the application/library ignoring the signal for us, so we do it. O_NOSIGPIPE exists on the BSDs and I'll add it to Linux. If it isn't supported, then we need to ignore SIGPIPE globally. Change-Id: I25d85d86649448d5b2b3fffd1450f6afeaea8b18 Reviewed-by: Ralf Nolden <nolden@kde.org> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
* | Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/devLiang Qi2016-01-261-1/+1
|\|
| * Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2016-01-191-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: config.tests/common/atomic64/atomic64.cpp configure src/3rdparty/forkfd/forkfd.c src/corelib/io/forkfd_qt.cpp src/widgets/kernel/qwidgetwindow.cpp tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tools/configure/configureapp.cpp Change-Id: Ic6168d82e51a0ef1862c3a63bee6722e8f138414
| | * forkfd: Only enable pipe2 on FreeBSD >= 10.0.Raphael Kubo da Costa2016-01-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The system call is not present on earlier releases, and since the 9.x series will be supported until the end of 2016, add a check for the __FreeBSD_version macro and only enable pipe2 support if the value is high enough. Change-Id: I5633531cec7e95d42ff5f4b14afe772ae8d7d66d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * forkfd: Define __BSD_VISIBLE and _NETBSD_SOURCE.Raphael Kubo da Costa2015-12-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pipe2's availability on BSD operating systems depends on the __BSD_VISIBLE macro on FreeBSD and OpenBSD and _NETBSD_SOURCE on NetBSD (DragonFly BSD appears to define it unconditionally). Those two macros are generally set by default, except when _POSIX_C_SOURCE is set. Since we consciously set _POSIX_C_SOURCE but need pipe2, explicitly define the visibility macros. This fixes the -no-pch build on FreeBSD at least. Change-Id: Icc77f6b5d1f9a5bf7bd8048cabbb01f8f89397cc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Update the Intel copyright yearThiago Macieira2016-01-213-3/+3
|/ / | | | | | | | | | | | | | | | | Not that we require it, but since The Qt Company did it for all files they have copyright, even if they haven't touched the file in years (especially not in 2016), I'm doing the same. Change-Id: I7a9e11d7b64a4cc78e24ffff142b4c9d53039846 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-11-041-0/+3
|\| | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qstorageinfo_unix.cpp src/plugins/platforms/windows/qwindowsmousehandler.cpp src/widgets/styles/qwindowsvistastyle.cpp Change-Id: Ie1725933815891cc8c86258d4c0e8ed0ab386edf
| * Undef HAVE_WAITID if needed constants are not definedDmitry Shachnev2015-10-261-0/+3
| | | | | | | | | | | | | | | | | | That is the case on Hurd, where the code currently breaks because Hurd does not have WEXITED or WNOWAIT defined. Change-Id: I4b13633612b1168d36c949d9e8b35bc05bca7d5c Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-10-022-5/+5
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/doc/src/qmake-manual.qdoc src/corelib/tools/qstring.h src/gui/image/qimagereader.cpp src/network/access/qnetworkaccessmanager.cpp src/tools/qdoc/doc/examples/examples.qdoc src/widgets/accessible/qaccessiblewidgetfactory_p.h src/widgets/doc/qtwidgets.qdocconf Change-Id: I8fae62283aebefe24e5ca4b4abd97386560c0fcb
| * Fix detection of uClibc version numbersThiago Macieira2015-09-211-2/+2
| | | | | | | | | | | | | | | | Major << 16 is 0x90000. Reported in QTBUG-45139 Change-Id: I42e7ef1a481840699a8dffff14057022bc4df8e9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
| * forkfd: fix _POSIX_SPAWN feature checkLouai Al-Khanji2015-09-042-3/+3
| | | | | | | | | | Change-Id: Ia44edbac3a1bd2da92ee8c92956abfe49d8763b8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | forkfd: Add support for FreeBSD's pdfork(2) system callThiago Macieira2015-08-111-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pdfork(2) has semantics very close to what we want in forkfd, but not quite. Differences: - we still get SIGCHLD and need to do a wait4 - no support for atomic FD_CLOEXEC and O_NONBLOCK On the SIGCHLD case: this commit is an improvement over the generic Unix case, since we no longer need to install a SIGCHLD handler and do not need to keep the arrays for matching PIDs and file descriptors. That matching is done entirely inside the kernel. However, since SIGCHLD is still sent to the process, an uncooperative SIGCHLD handler can still "steal" our response. At least Glib is documented not to reap children it wasn't explicitly asked to watch for (source code matches), but other libraries are known to do waitpid(-1) (e.g., EFL's Ecore). At least now the behavior is consistent: we will never install a handler, so the behavior won't depend on the order in which the handlers are installed. Change-Id: Iee8cbc07c4434ce9b560ffff13cb4c63306e43ef Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.5' into devFrederik Gladhorn2015-08-061-2/+8
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: doc/global/qt-cpp-defines.qdocconf src/3rdparty/forkfd/forkfd.c src/corelib/codecs/qtextcodec.cpp src/corelib/kernel/qmetatype.cpp src/corelib/tools/qset.qdoc src/gui/accessible/qaccessible.cpp src/gui/image/qpixmapcache.cpp src/opengl/qgl.cpp src/tools/qdoc/generator.cpp src/widgets/kernel/qwidget.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp Change-Id: I4fbe1fa756a54c6843aa75f4ef70a1069ba7b085
| * FreeBSD has pipe2, so enable it in forkfd.cThiago Macieira2015-08-061-0/+4
| | | | | | | | | | Change-Id: Ib056b47dde3341ef9a52ffff13efd1a15748e44d Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>