2018-11-29 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in the 'RDTextFile()' function that caused zombification
	of client programs.
This commit is contained in:
Fred Gleason 2018-11-29 16:50:42 -05:00
parent a9a3f385ad
commit dbc7d4e327
5 changed files with 37 additions and 11 deletions

View File

@ -18070,3 +18070,6 @@
* Incremented the database version to 301.
* Added an 'Inlcude Import Markers in Finished Logs' checkbox to
the 'Edit Service' dialog in rdadmin(1).
2018-11-29 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in the 'RDTextFile()' function that caused zombification
of client programs.

View File

@ -28,6 +28,15 @@
#include "rdcmd_switch.h"
RDApplication *rda=NULL;
QStringList __rdapplication_temp_files;
void __RDApplication_ExitCallback()
{
for(int i=0;i<__rdapplication_temp_files.size();i++) {
unlink(__rdapplication_temp_files.at(i).toUtf8());
}
}
RDApplication::RDApplication(const QString &module_name,const QString &cmdname,
const QString &usage,QObject *parent)
@ -49,6 +58,8 @@ RDApplication::RDApplication(const QString &module_name,const QString &cmdname,
app_station=NULL;
app_system=NULL;
app_user=NULL;
atexit(__RDApplication_ExitCallback);
}
@ -260,6 +271,12 @@ bool RDApplication::dropTable(const QString &tbl_name)
}
void RDApplication::addTempFile(const QString &pathname)
{
__rdapplication_temp_files.push_back(pathname);
}
void RDApplication::userChangedData()
{
app_user->setName(app_ripc->user());

View File

@ -22,6 +22,7 @@
#define RDAPPLICATION_H
#include <qobject.h>
#include <qstringlist.h>
#include <rdairplay_conf.h>
#include <rdcae.h>
@ -58,6 +59,7 @@ class RDApplication : public QObject
RDUser *user();
void log(RDConfig::LogPriority prio,const QString &msg);
bool dropTable(const QString &tbl_name);
void addTempFile(const QString &pathname);
private slots:
void userChangedData();

View File

@ -18,30 +18,30 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <q3process.h>
#include "rdapplication.h"
#include "rdconf.h"
#include "rd.h"
#include "rdtempdirectory.h"
#include <rdtextfile.h>
bool RDTextFile(const QString &data)
bool RDTextFile(const QString &data,bool delete_on_exit)
{
char tmpfile[256];
QString editor;
char editor[256];
if(getenv("VISUAL")==NULL) {
editor=RD_LINUX_EDITOR;
strncpy(editor,RD_LINUX_EDITOR,256);
}
else {
editor=getenv("VISUAL");
strncpy(editor,getenv("VISUAL"),256);
}
strcpy(tmpfile,RDTempDirectory::basePath()+"/rdreportXXXXXX");
int fd=mkstemp(tmpfile);
@ -51,10 +51,14 @@ bool RDTextFile(const QString &data)
}
write(fd,data.utf8(),data.utf8().length());
::close(fd);
if(delete_on_exit) {
rda->addTempFile(tmpfile);
}
char *args[]={editor,tmpfile,(char *)NULL};
if(fork()==0) {
system(editor+" "+QString(tmpfile));
unlink(tmpfile);
exit(0);
execvp(editor,args);
exit(1);
}
return true;
}

View File

@ -23,7 +23,7 @@
#include <qstring.h>
bool RDTextFile(const QString &data);
bool RDTextFile(const QString &data,bool delete_on_exit=true);
#endif // RDTEXTFILE_H