-.TH "zypper" "8" "1.2.4" "zypper" "System Tools"
+.TH "zypper" "8" "1.2.5" "zypper" "System Tools"
.SH "SYNTAX"
.LP
zypper [\fI\-\-global\-opts\fR] <\fBcommand\fR> [\fI\-\-command\-opts\fR] [\fBcommand-arguments\fR]
.TP
.B removelock (rl) [options] <lock-number|package-name> ...
-Remove specified package lock. Specify the lock to remove by its number obtained with 'zypper locks'
+Remove specified package lock. Specify the lock to remove by its number obtained with \fBzypper locks\fR
or by the package name.
.TP
This command can be useful for companies redistributiong a custom
distribution (like appliances) to figure out what licenses they are bound by.
+.TP
+.B ps
+After each upgrade or removal of packages, there may be running processes
+on the system which then use files meanwhile deleted by the upgrade.
+\fBzypper ps\fR lists these processes, together with the corresponding
+deleted files, and a service name hint, in case it's a known service.
+The list contains the following information:
+
+* PID\ \ \ \ \ \ ID of the process
+.br
+* PPID\ \ \ \ \ ID of the parent process
+.br
+* UID\ \ \ \ \ \ ID of the user running the process
+.br
+* Login\ \ \ \ login name of the user running the process
+.br
+* Command\ \ command used to execute the process
+.br
+* Service\ \ guessed name of the service. If an init script exists for this
+ \ \ \ \ \ \ \ \ \ \ service, you can do "rcservicename restart" to restart it.
+.br
+* Files\ \ \ \ the list of the deleted files
+
.SH "GLOBAL OPTIONS"
as if there were no packages installed in the system. Use with caution as you
can damage your system using this option.
-.SH "NOTES"
-.TP
-.B Notification About Running Processes Using Deleted Files
-After each upgrade or removal of packages Zypper checks whether
-there are any runing processes that may be using files recently
-deleted by an upgrade or package removal. If such processes are
-found, zypper will list them in a table having the following columns:
-
-* PID\ \ \ \ \ \ ID of the process
-.br
-* PPID\ \ \ \ \ ID of the parent process
-.br
-* UID\ \ \ \ \ \ ID of the user running the process
-.br
-* Login\ \ \ \ login name of the user running the process
-.br
-* Command\ \ command used to execute the process
-.br
-* Service\ \ guessed name of the service. If an init script exists for this
- \ \ \ \ \ \ \ \ \ \ service, you can do "rcservicename restart" to restart it.
-.br
-* Files\ \ \ \ the list of the deleted files
.SH "FILES"
.TP
const ZypperCommand ZypperCommand::TARGET_OS(ZypperCommand::TARGET_OS_e);
const ZypperCommand ZypperCommand::VERSION_CMP(ZypperCommand::VERSION_CMP_e);
const ZypperCommand ZypperCommand::LICENSES(ZypperCommand::LICENSES_e);
+const ZypperCommand ZypperCommand::PS(ZypperCommand::PS_e);
const ZypperCommand ZypperCommand::HELP(ZypperCommand::HELP_e);
const ZypperCommand ZypperCommand::SHELL(ZypperCommand::SHELL_e);
_table["targetos"] = _table["tos"] = ZypperCommand::TARGET_OS_e;
_table["versioncmp"] = _table["vcmp"] = ZypperCommand::VERSION_CMP_e;
_table["licenses"] = ZypperCommand::LICENSES_e;
+ _table["ps"] = ZypperCommand::PS_e;
_table["help"] = _table["?"] = ZypperCommand::HELP_e;
_table["shell"] = _table["sh"] = ZypperCommand::SHELL_e;
static const ZypperCommand TARGET_OS;
static const ZypperCommand VERSION_CMP;
static const ZypperCommand LICENSES;
+ static const ZypperCommand PS;
static const ZypperCommand HELP;
static const ZypperCommand SHELL;
TARGET_OS_e = 80,
VERSION_CMP_e = 81,
LICENSES_e = 82,
+ PS_e = 83,
HELP_e = 90,
SHELL_e = 91,
break;
}
+
+ case ZypperCommand::PS_e:
+ {
+ static struct option options[] =
+ {
+ {"help", no_argument, 0, 'h'},
+ {0, 0, 0, 0}
+ };
+ specific_options = options;
+ _command_help = _(
+ "ps\n"
+ "\n"
+ "List running processes which use files deleted by recent upgrades.\n"
+ "\n"
+ "This command has no additional options.\n"
+ );
+ break;
+ }
+
+
case ZypperCommand::SHELL_QUIT_e:
{
static struct option quit_options[] = {
break;
}
+
+ case ZypperCommand::PS_e:
+ {
+ if (runningHelp()) { out().info(_command_help, Out::QUIET); return; }
+
+ if (!_arguments.empty())
+ {
+ report_too_many_arguments(_command_help);
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
+ }
+
+ list_processes_using_deleted_files(*this);
+
+ break;
+ }
+
+
// -----------------------------( shell )------------------------------------
case ZypperCommand::SHELL_QUIT_e:
#include "utils/misc.h"
#include "utils/prompt.h" // Continue? and solver problem prompt
#include "utils/pager.h" // to view the summary
-#include "Table.h" // for process list in suggest_restart_services
#include "Summary.h"
#include "solve-commit.h"
}
/** fate #300763
- * This is called after each commit to show running processes that use
- * libraries or other files that have been removed since their execution.
- * This is particularly useful after zypper remove or zypper update.
+ * This is called after each commit to notify user about running processes that
+ * use libraries or other files that have been removed since their execution.
*/
-static void suggest_restart_services(Zypper & zypper)
+static void notify_processes_using_deleted_files(Zypper & zypper)
{
zypper.out().info(
_("Checking for running processes using deleted libraries..."), Out::HIGH);
zypper.out().error(e, _("Check failed:"));
}
- Table t;
- t.allowAbbrev(6);
- TableHeader th;
- // process ID
- th << _("PID");
- // parent process ID
- th << _("PPID");
- // process user ID
- th << _("UID");
- // process login name
- th << _("Login");
- // process command name
- th << _("Command");
- // "/etc/init.d/ script that might be used to restart the command (guessed)
- th << _("Service");
- // "list of deleted files or libraries accessed"
- th << _("Files");
- t << th;
-
- for_( it, checker.begin(), checker.end() )
+ if (checker.begin() != checker.end())
{
- TableRow tr;
- vector<string>::const_iterator fit = it->files.begin();
- tr << it->pid << it->ppid << it->puid << it->login << it->command
- << it->service() << (fit != it->files.end() ? *fit : "");
- t << tr;
- for (; fit != it->files.end(); ++fit)
- {
- TableRow tr1;
- tr1 << "" << "" << "" << "" << "" << "" << *fit;
- t << tr1;
- }
- }
-
- if (t.empty())
- {
- zypper.out().info(_("No such processes found."), Out::HIGH);
- }
- else
- {
- cout << endl;
- zypper.out().info(_("The following running processes use deleted files:"));
- cout << endl;
- cout << t << endl;
- zypper.out().info(_("You may wish to restart these processes."));
zypper.out().info(str::form(
- _("See '%s' for information about the meaning of values"
- " in the above table."),
- "man zypper"));
+ _("There are some running programs that use files deleted by recent upgrade."
+ " You may wish to restart some of them. Run '%s' to list these programs."),
+ "zypper ps"));
}
}
if (summary.packagesToRemove() ||
summary.packagesToUpgrade() ||
summary.packagesToDowngrade())
- suggest_restart_services(zypper);
+ notify_processes_using_deleted_files(zypper);
}
}
// noting to do
#include <fstream>
#include <sstream>
+#include <iostream>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
#include "zypp/base/String.h"
#include "zypp/media/MediaManager.h"
#include "zypp/parser/xml/XmlEscape.h"
+#include "zypp/misc/CheckAccessDeleted.h"
#include "zypp/PoolItem.h"
#include "zypp/Product.h"
#include "main.h"
#include "Zypper.h"
+#include "Table.h" // for process list in suggest_restart_services
#include "utils/misc.h"
}
// ----------------------------------------------------------------------------
+
+void list_processes_using_deleted_files(Zypper & zypper)
+{
+ zypper.out().info(
+ _("Checking for running processes using deleted libraries..."), Out::HIGH);
+ zypp::CheckAccessDeleted checker(false); // wait for explicit call to check()
+ try
+ {
+ checker.check();
+ }
+ catch(const zypp::Exception & e)
+ {
+ if (zypper.out().verbosity() > Out::NORMAL)
+ zypper.out().error(e, _("Check failed:"));
+ }
+
+ Table t;
+ t.allowAbbrev(6);
+ TableHeader th;
+ // process ID
+ th << _("PID");
+ // parent process ID
+ th << _("PPID");
+ // process user ID
+ th << _("UID");
+ // process login name
+ th << _("Login");
+ // process command name
+ th << _("Command");
+ // "/etc/init.d/ script that might be used to restart the command (guessed)
+ th << _("Service");
+ // "list of deleted files or libraries accessed"
+ th << _("Files");
+ t << th;
+
+ for_( it, checker.begin(), checker.end() )
+ {
+ TableRow tr;
+ vector<string>::const_iterator fit = it->files.begin();
+ tr << it->pid << it->ppid << it->puid << it->login << it->command
+ << it->service() << (fit != it->files.end() ? *fit : "");
+ t << tr;
+ for (; fit != it->files.end(); ++fit)
+ {
+ TableRow tr1;
+ tr1 << "" << "" << "" << "" << "" << "" << *fit;
+ t << tr1;
+ }
+ }
+
+ if (t.empty())
+ {
+ zypper.out().info(_("No processes using deleted files found."));
+ }
+ else
+ {
+ zypper.out().info(_("The following running processes use deleted files:"));
+ cout << endl;
+ cout << t << endl;
+ zypper.out().info(_("You may wish to restart these processes."));
+ zypper.out().info(str::form(
+ _("See '%s' for information about the meaning of values"
+ " in the above table."),
+ "man zypper"));
+ }
+}
std::string asXML(const zypp::Pattern & p, bool is_installed);
+/**
+ * fate #300763
+ * Used by 'zypper ps' to show running processes that use
+ * libraries or other files that have been removed since their execution.
+ * This is particularly useful after 'zypper remove' or 'zypper update'.
+ */
+void list_processes_using_deleted_files(Zypper & zypper);
+
#endif /*ZYPPER_UTILS_H*/