Changeset View
Changeset View
Standalone View
Standalone View
devel/qt5-core/files/patch-src_corelib_io_qlockfile__unix.cpp
- This file was added.
--- src/corelib/io/qlockfile_unix.cpp.orig 2018-06-06 09:26:40 UTC | |||||
+++ src/corelib/io/qlockfile_unix.cpp | |||||
@@ -75,6 +75,8 @@ | |||||
# include <sys/sysctl.h> | |||||
# if !defined(Q_OS_NETBSD) | |||||
# include <sys/user.h> | |||||
+# include <kvm.h> | |||||
+# include <libprocstat.h> | |||||
# endif | |||||
#endif | |||||
@@ -246,23 +248,43 @@ QString QLockFilePrivate::processNameByPid(qint64 pid) | |||||
rakuco: Isn't it easier to just add a `freebsd` condition in the else block below?
```
} else {… | |||||
struct kinfo_proc kp; | |||||
int mib[6] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid, sizeof(struct kinfo_proc), 1 }; | |||||
# else | |||||
+ kvm_t * kvm = kvm_open(nullptr, "/dev/null", nullptr, O_RDONLY, ""); | |||||
tcbernerUnsubmitted Done Inline Actions^ shouldn't there be some chekc on the return value of kvm_open? tcberner: ^ shouldn't there be some chekc on the return value of kvm_open? | |||||
+ int cnt; | |||||
+ struct kinfo_proc * kvm_kp = kvm_getprocs(kvm, KERN_PROC_PID, getpid(), &cnt); | |||||
+ struct procstat * ps = procstat_open_sysctl(); | |||||
+ char ** argv = procstat_getargv(ps, kvm_kp, 0); | |||||
+ QString nameFromProcstat; | |||||
+ if (argv != nullptr && argv[0] != nullptr) | |||||
+ nameFromProcstat = QString::fromLocal8Bit(argv[0]); | |||||
+ procstat_close(ps); | |||||
+ kvm_close(kvm); | |||||
+ | |||||
struct kinfo_proc kp; | |||||
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid }; | |||||
# endif | |||||
- size_t len = sizeof(kp); | |||||
- u_int mib_len = sizeof(mib)/sizeof(u_int); | |||||
+ if (nameFromProcstat.isEmpty()) | |||||
+ { | |||||
+ size_t len = sizeof(kp); | |||||
+ u_int mib_len = sizeof(mib)/sizeof(u_int); | |||||
Done Inline ActionsStyle: the * needs to be next to kp (this applies to the other pointer declarations below too). rakuco: Style: the `*` needs to be next to `kp` (this applies to the other pointer declarations below… | |||||
- if (sysctl(mib, mib_len, &kp, &len, NULL, 0) < 0) | |||||
- return QString(); | |||||
- | |||||
+ if (sysctl(mib, mib_len, &kp, &len, NULL, 0) < 0) | |||||
+ return QString(); | |||||
+ } | |||||
# if defined(Q_OS_OPENBSD) || defined(Q_OS_NETBSD) | |||||
if (kp.p_pid != pid) | |||||
return QString(); | |||||
QString name = QFile::decodeName(kp.p_comm); | |||||
# else | |||||
- if (kp.ki_pid != pid) | |||||
+ QString name; | |||||
+ if (!nameFromProcstat.isEmpty()) | |||||
+ { | |||||
Done Inline ActionsStyle: this should've been part of the previous line. rakuco: Style: this should've been part of the previous line. | |||||
+ QFileInfo fi(nameFromProcstat); | |||||
+ name = fi.fileName(); | |||||
+ } | |||||
+ else if (kp.ki_pid != pid) | |||||
return QString(); | |||||
- QString name = QFile::decodeName(kp.ki_comm); | |||||
+ else | |||||
+ QString name = QFile::decodeName(kp.ki_comm); | |||||
tcbernerUnsubmitted Done Inline Actions^ name is already defined on line 49. tcberner: ^ name is already defined on line 49. | |||||
# endif | |||||
return name; | |||||
--- src/corelib/io/io.pri.orig 2018-02-08 18:24:48 UTC | |||||
+++ src/corelib/io/io.pri | |||||
@@ -174,6 +174,11 @@ win32 { | |||||
io/qstandardpaths_haiku.cpp \ | |||||
io/qstorageinfo_unix.cpp | |||||
LIBS += -lbe | |||||
+ } else:freebsd { | |||||
Done Inline ActionsSame here. rakuco: Same here. | |||||
+ SOURCES += \ | |||||
+ io/qstandardpaths_unix.cpp \ | |||||
+ io/qstorageinfo_unix.cpp | |||||
+ LIBS += -lkvm -lprocstat | |||||
} else { | |||||
SOURCES += \ | |||||
io/qstandardpaths_unix.cpp \ | |||||
No newline at end of file |
Isn't it easier to just add a freebsd condition in the else block below?