By default we inherit file descriptors from the parent in
the worker process. This is a leak of resources since the
worker won't be able to do anything with them. Also, in
the case of CIFS this causes locks which might lead to bad
surprises in the parent process.
Gbp-Pq: Name fix_cifs_file_locks.patch
#include <QPluginLoader>
#include <QString>
+#ifdef Q_OS_UNIX
+#include <sys/resource.h>
+#endif
+
#ifdef Q_OS_WIN
#include <QProcess>
#include <QStandardPaths>
int main(int argc, char **argv)
{
+#ifdef Q_OS_UNIX
+ int max_fd = INT_MAX;
+ struct rlimit limit;
+ if (getrlimit(RLIMIT_NOFILE, &limit) == 0) {
+ max_fd = limit.rlim_cur;
+ }
+ for (int fd = STDERR_FILENO + 1; fd < max_fd; fd++) {
+ ::close(fd);
+ }
+#endif
+
if (argc < 5) {
fprintf(stderr, "Usage: kioslave5 <slave-lib> <protocol> <klauncher-socket> <app-socket>\n\nThis program is part of KDE.\n");
return 1;