Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=cd1299d633dc195d75d4c64c47a37bb65521e8dd

commit cd1299d633dc195d75d4c64c47a37bb65521e8dd
Author: Miklos Vajna <vmik...@frugalware.org>
Date:   Sun May 15 02:43:24 2011 +0200

pacman -S: adverties pacman -P in case it has some output

diff --git a/src/pacman-g2/pacman-g2.c b/src/pacman-g2/pacman-g2.c
index 4d84869..aa3842b 100644
--- a/src/pacman-g2/pacman-g2.c
+++ b/src/pacman-g2/pacman-g2.c
@@ -654,7 +654,7 @@ int main(int argc, char *argv[])
case PM_OP_UPGRADE: ret = upgradepkg(pm_targets); break;
case PM_OP_QUERY:   ret = querypkg(pm_targets);   break;
case PM_OP_SYNC:    ret = syncpkg(pm_targets);    break;
-               case PM_OP_PS:      ret = pspkg();      break;
+               case PM_OP_PS:      ret = pspkg(0);      break;
case PM_OP_DEPTEST: ret = deptestpkg(pm_targets); break;
default:
ERR(NL, _("no operation specified (use -h for help)\n"));
diff --git a/src/pacman-g2/ps.c b/src/pacman-g2/ps.c
index e18736c..cd31e07 100644
--- a/src/pacman-g2/ps.c
+++ b/src/pacman-g2/ps.c
@@ -190,11 +190,12 @@ static list_t* ps_parse(FILE *fp)
return ret;
}

-int pspkg()
+int pspkg(int countonly)
{
FILE *fpout = NULL;
pid_t pid;
list_t* i;
+       int count = 0;

if (strcmp(config->root, "/") != 0) {
ERR(NL, _("changing root directory is not supported when listing open 
files.\n"));
@@ -210,19 +211,22 @@ int pspkg()
ps_t *ps = i->data;
if (!ps)
continue;
-               printf(      _("User    : %s\n"), ps->user);
-               printf(      _("PID     : %d\n"), ps->pid);
-               printf(      _("Command : %s\n"), ps->cmd);
-               list_display(_("Files   :"), ps->files);
-               list_display(_("CGroups :"), ps->cgroups);
-               ps_free(ps);
-               printf("\n");
+               if (!countonly) {
+                       printf(      _("User    : %s\n"), ps->user);
+                       printf(      _("PID     : %d\n"), ps->pid);
+                       printf(      _("Command : %s\n"), ps->cmd);
+                       list_display(_("Files   :"), ps->files);
+                       list_display(_("CGroups :"), ps->cgroups);
+                       ps_free(ps);
+                       printf("\n");
+               }
+               count++;
}
FREELISTPTR(ret);

end_lsof(fpout, pid);

-       return 0;
+       return count;
}

/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman-g2/ps.h b/src/pacman-g2/ps.h
index dcaec9e..68d9301 100644
--- a/src/pacman-g2/ps.h
+++ b/src/pacman-g2/ps.h
@@ -29,7 +29,7 @@ typedef struct __ps_t {
list_t *cgroups;
} ps_t;

-int pspkg();
+int pspkg(int countonly);

#endif /* _PM_PS_H */

diff --git a/src/pacman-g2/sync.c b/src/pacman-g2/sync.c
index c5b3781..b2899b0 100644
--- a/src/pacman-g2/sync.c
+++ b/src/pacman-g2/sync.c
@@ -45,6 +45,7 @@
#include "list.h"
#include "package.h"
#include "trans.h"
+#include "ps.h"
#include "sync.h"
#include "conf.h"

@@ -639,6 +640,10 @@ int syncpkg(list_t *targets)
retval = 1;
goto cleanup;
}
+       if (pspkg(1) > 0) {
+               MSG(NL, _(":: There are running processes that use files 
deleted by pacman-g2.\n"));
+               MSG(NL, _(":: You may wish to restart some of them. Run '%s' to 
list them.\n"), "pacman-g2 -P");
+       }

/* Step 4: release transaction resources
*/
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to