Changeset View
Changeset View
Standalone View
Standalone View
src/ProcessInfo.cpp
Show First 20 Lines • Show All 573 Lines • ▼ Show 20 Line(s) | 450 | private: | |||
---|---|---|---|---|---|
574 | { | 574 | { | ||
575 | // read command-line arguments file found at /proc/<pid>/cmdline | 575 | // read command-line arguments file found at /proc/<pid>/cmdline | ||
576 | // the expected format is a list of strings delimited by null characters, | 576 | // the expected format is a list of strings delimited by null characters, | ||
577 | // and ending in a double null character pair. | 577 | // and ending in a double null character pair. | ||
578 | 578 | | |||
579 | QFile argumentsFile(QStringLiteral("/proc/%1/cmdline").arg(pid)); | 579 | QFile argumentsFile(QStringLiteral("/proc/%1/cmdline").arg(pid)); | ||
580 | if (argumentsFile.open(QIODevice::ReadOnly)) { | 580 | if (argumentsFile.open(QIODevice::ReadOnly)) { | ||
581 | QTextStream stream(&argumentsFile); | 581 | QTextStream stream(&argumentsFile); | ||
582 | const QString &data = stream.readAll(); | | |||
583 | | ||||
584 | const QStringList &argList = data.split(QLatin1Char('\0')); | | |||
585 | 582 | | |||
586 | foreach (const QString &entry, argList) { | 583 | for (const auto &entry : stream.readAll().split(QLatin1Char('\0'))) { | ||
587 | if (!entry.isEmpty()) { | 584 | if (!entry.isEmpty()) { | ||
588 | addArgument(entry); | 585 | addArgument(entry); | ||
589 | } | 586 | } | ||
590 | } | 587 | } | ||
591 | } else { | 588 | } else { | ||
592 | setFileError(argumentsFile.error()); | 589 | setFileError(argumentsFile.error()); | ||
593 | } | 590 | } | ||
594 | 591 | | |||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 694 | { | |||
706 | 703 | | |||
707 | len = sizeof(args); | 704 | len = sizeof(args); | ||
708 | if (sysctl(managementInfoBase, 4, args, &len, NULL, 0) == -1) { | 705 | if (sysctl(managementInfoBase, 4, args, &len, NULL, 0) == -1) { | ||
709 | return false; | 706 | return false; | ||
710 | } | 707 | } | ||
711 | 708 | | |||
712 | // len holds the length of the string | 709 | // len holds the length of the string | ||
713 | QString qargs = QString::fromLocal8Bit(args, len); | 710 | QString qargs = QString::fromLocal8Bit(args, len); | ||
714 | foreach (const QString &value, qargs.split(QLatin1Char('\u0000'))) { | 711 | for (const auto &value : qargs.split(QLatin1Char('\u0000'))) { | ||
715 | if (!value.isEmpty()) { | 712 | if (!value.isEmpty()) { | ||
716 | addArgument(value); | 713 | addArgument(value); | ||
717 | } | 714 | } | ||
718 | } | 715 | } | ||
719 | 716 | | |||
720 | return true; | 717 | return true; | ||
721 | } | 718 | } | ||
722 | }; | 719 | }; | ||
▲ Show 20 Lines • Show All 474 Lines • Show Last 20 Lines |