Fix cupsd process detection

(cherry picked from commit 754647ba5a)
v3.5.13-sru
François Andriot 10 years ago committed by Slávek Banko
parent 6cbb86f9ae
commit 50c0b04fd4

@ -44,6 +44,7 @@
#include <kio/passdlg.h> #include <kio/passdlg.h>
#include <kguiitem.h> #include <kguiitem.h>
#include <kprocess.h> #include <kprocess.h>
#include <tqprocess.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
@ -70,6 +71,18 @@ extern "C"
int getServerPid() int getServerPid()
{ {
#if defined(__OpenBSD__)
TQProcess *proc = new TQProcess();
proc->addArgument("pgrep");
proc->addArgument("cupsd");
proc->start();
while (proc->isRunning()); //Wait for process to exit
TQString pidString = proc->readLineStdout();
bool ok;
int pid = pidString.toInt(&ok);
if (ok) return pid;
return (-1);
#else
TQDir dir("/proc",TQString::null,TQDir::Name,TQDir::Dirs); TQDir dir("/proc",TQString::null,TQDir::Name,TQDir::Dirs);
for (uint i=0;i<dir.count();i++) for (uint i=0;i<dir.count();i++)
{ {
@ -88,6 +101,7 @@ int getServerPid()
} }
} }
return (-1); return (-1);
#endif
} }
const char* getPassword(const char*) const char* getPassword(const char*)

Loading…
Cancel
Save