| 119 | |
| 120 | #if defined(Q_OS_FREEBSD) || defined(Q_OS_OPEN_BSD) || defined(Q_OS_MACOS) |
| 121 | QSharedPointer<struct kinfo_proc> UnixProcessInfo::getProcInfoStruct(int *managementInfoBase, int mibCount) |
| 122 | { |
| 123 | size_t structLength; |
| 124 | |
| 125 | if (::sysctl(managementInfoBase, mibCount, NULL, &structLength, NULL, 0) == -1) { |
| 126 | qWarning() << "first sysctl() call failed with code " << errno; |
| 127 | return nullptr; |
| 128 | } |
| 129 | |
| 130 | QSharedPointer<struct kinfo_proc> kInfoProc(new struct kinfo_proc[structLength]); |
| 131 | |
| 132 | if (::sysctl(managementInfoBase, mibCount, kInfoProc.get(), &structLength, NULL, 0) == -1) { |
| 133 | qWarning() << "second sysctl() call failed with code " << errno; |
| 134 | return nullptr; |
| 135 | } |
| 136 | |
| 137 | return kInfoProc; |
| 138 | } |
| 139 | #endif |
| 140 | |
| 141 | #endif // Q_OS_WIN |