- Fix process handling routines. Do not issue external ps(1) commands, but

use kvm instead.
- Fix the codelite_kill_children shell script
This commit is contained in:
Pietro Cerutti 2009-05-23 11:52:52 +00:00
parent f329d18870
commit 6771940e88
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=234433
3 changed files with 123 additions and 19 deletions

View File

@ -0,0 +1,101 @@
--- CodeLite/procutils.cpp.orig 2009-01-09 17:34:59.000000000 +0100
+++ CodeLite/procutils.cpp 2009-05-23 13:45:05.000000000 +0200
@@ -40,6 +40,15 @@
#endif
+#ifdef __FreeBSD__
+#include <kvm.h>
+#include <fcntl.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+#include <paths.h>
+#endif
+
ProcUtils::ProcUtils()
{
}
@@ -135,6 +144,24 @@
CloseHandle( hModuleSnap );
return me32.szExePath;
+#elif defined(__FreeBSD__)
+ kvm_t *kvd;
+ struct kinfo_proc *ki;
+ int nof_procs;
+ wxString cmd;
+
+ if (!(kvd = kvm_openfiles(_PATH_DEVNULL, _PATH_DEVNULL, NULL, O_RDONLY, NULL)))
+ return wxEmptyString;
+
+ if (!(ki = kvm_getprocs(kvd, KERN_PROC_PID, pid, &nof_procs))) {
+ kvm_close(kvd);
+ return wxEmptyString;
+ }
+
+ cmd = wxString(ki->ki_ocomm, wxConvUTF8);
+ kvm_close(kvd);
+
+ return (cmd);
#else
wxArrayString output;
ExecuteCommand(wxT("ps -A -o pid,command --no-heading"), output);
@@ -223,6 +250,28 @@
proclist.push_back(entry);
} while (Process32Next (hProcessSnap, &pe));
CloseHandle (hProcessSnap);
+
+#elif defined(__FreeBSD__)
+ kvm_t *kvd;
+ struct kinfo_proc *ki;
+ int nof_procs, i;
+
+ if (!(kvd = kvm_openfiles(_PATH_DEVNULL, _PATH_DEVNULL, NULL, O_RDONLY, NULL)))
+ return;
+
+ if (!(ki = kvm_getprocs(kvd, KERN_PROC_PROC, 0, &nof_procs))) {
+ kvm_close(kvd);
+ return;
+ }
+
+ for (i=0; i<nof_procs; i++) {
+ ProcessEntry entry;
+ entry.pid = ki[i].ki_pid;
+ entry.name = wxString(ki[i].ki_ocomm, wxConvUTF8);
+ proclist.push_back(entry);
+ }
+ kvm_close(kvd);
+
#else
//GTK and other
wxArrayString output;
@@ -299,6 +348,28 @@
}
} while (Process32Next (hProcessSnap, &pe));
CloseHandle (hProcessSnap);
+
+#elif defined(__FreeBSD__)
+ kvm_t *kvd;
+ struct kinfo_proc *ki;
+ int nof_procs, i;
+
+ if (!(kvd = kvm_openfiles(_PATH_DEVNULL, _PATH_DEVNULL, NULL, O_RDONLY, NULL)))
+ return;
+
+ if (!(ki = kvm_getprocs(kvd, KERN_PROC_PROC, pid, &nof_procs))) {
+ kvm_close(kvd);
+ return;
+ }
+
+ for (i=0; i<nof_procs; i++) {
+ ProcessEntry entry;
+ if (ki[i].ki_ppid == pid)
+ proclist.push_back(ki[i].ki_pid);
+ }
+
+ kvm_close(kvd);
+
#else
//GTK and other
wxArrayString output;

View File

@ -0,0 +1,10 @@
--- Runtime/codelite_kill_children.orig 2009-05-23 13:23:08.000000000 +0200
+++ Runtime/codelite_kill_children 2009-05-23 13:41:35.000000000 +0200
@@ -1,6 +1,6 @@
#!/bin/sh
-procs=`ps --ppid $1 | grep -v PID | awk '{print $1;}'`
+procs=`ps -A -o ppid,pid | grep -v PPID | awk '{print $1" "$2}' | grep "^$1 " | awk '{print $2}' | xargs`
for p in $procs
do
kill -9 $p

View File

@ -1,19 +1,12 @@
--- configure.orig 2008-05-14 19:24:35.000000000 +0200
+++ configure 2008-05-15 21:48:27.000000000 +0200
@@ -381,12 +383,10 @@
createEndMessage()
{
- if [ "$os_name" = "Linux" ]; then
- echo "post_build_msg:" >> Makefile
- echo " @echo ==========================================================" >> Makefile
- echo " @echo Done, please run \"sudo make install\"." >> Makefile
- echo " @echo ==========================================================" >> Makefile
- fi
+ echo "post_build_msg:" >> Makefile
+ echo " @echo ==========================================================" >> Makefile
+ echo " @echo Done, please run \"sudo make install\"." >> Makefile
+ echo " @echo ==========================================================" >> Makefile
}
## main
--- configure.orig 2009-03-12 13:14:45.000000000 +0100
+++ configure 2009-05-23 00:58:21.000000000 +0200
@@ -70,6 +70,9 @@
else
echo "CCFLAGS := \$(CCFLAGS) -D__APPLE__ -DMACOSX" >> Makefile
fi
+ if [ "$os_name" = "FreeBSD" ]; then
+ echo "LINK_FLAGS := \$(LINK_FLAGS) -lkvm" >> Makefile
+ fi
echo "INCLUDES := \$(INCLUDES) -I. -I${base_dir}/sdk/wxsqlite3/include -I${base_dir}/sdk/wxsqlite3/sqlite3/include -I${base_dir}/sdk/wxscintilla/include -I${base_dir}/sdk/wxscintilla/src/scintilla/include -I${base_dir}/sdk/wxpropgrid/include -I${base_dir}/sdk/wxscintilla/src/scintilla/src -I${base_dir}/Interfaces -I${base_dir}/Debugger -I${base_dir}/Plugin -I${base_dir}/CodeLite " >> Makefile
echo "" >> Makefile
echo "" >> Makefile