home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Linux
/
Divers
/
lyx-0.13.2.tar.gz
/
lyx-0.13.2.tar
/
lyx-0.13.2
/
src
/
figinset.C
< prev
next >
Wrap
C/C++ Source or Header
|
1998-04-23
|
3KB
|
130 lines
/*
* figinset.C - part of LyX project
*/
#include <config.h>
#include <unistd.h>
//#include <signal.h>
#include <sys/wait.h>
#if defined(sgi) && !defined(__GNUC__)
#include <bstring.h>
#endif
#include <stdlib.h>
#include "lyx_main.h"
#include "error.h"
#include "procMgr.h"
#include "insetfig.h"
#include "figlist.h"
#include "gsqueue.h"
// $Id: figinset.C,v 1.1.1.1 1998/04/23 16:02:49 larsbj Exp $
#if !defined(lint) && !defined(WITH_WARNINGS)
static char vcid[] = "$Id: figinset.C,v 1.1.1.1 1998/04/23 16:02:49 larsbj Exp $";
#endif /* lint */
//extern void sigchldhandler(int sig);
extern void UpdateInset(Inset* inset, bool mark_dirty = true);
// better for asyncron updating:
extern void PutInsetIntoInsetUpdateList(Inset* inset);
extern void ProhibitInput();
extern void AllowInput();
int bmpinsref = 0; // number of bitmaps
extern Colormap color_map;
static void makeupdatelist(figdata *p)
{
int i;
for (i = 0; i < figL.figinsref; ++i) if (figL.figures[i]->data == p) {
if (lyxerr.debugging()) {
lyxerr.print(LString("Updating inset ")
+ long(figL.figures[i]->inset));
}
// add inset figures[i]->inset into to_update list
PutInsetIntoInsetUpdateList(figL.figures[i]->inset);
}
}
void sigchldchecker(int)
{
int i, status;
figdata *p;
int pid = 0;
for (i = bmpinsref - 1; i >= 0; --i)
if (figL.bitmaps[i]->reading && figL.bitmaps[i]->gspid > 0)
if ((pid = waitpid(figL.bitmaps[i]->gspid, &status, WNOHANG)) ==
figL.bitmaps[i]->gspid) {
// now read the file and remove it from disk
p = figL.bitmaps[i];
p->reading = false;
if (figL.bitmaps[i]->gsdone) status = 0;
if (lyxerr.debugging()) {
if (status == 0) {
printf("GS [%d] exit OK.\n", pid);
} else {
printf("GS [%d] error %d E:%d %d S:%d %d\n", pid,
status, WIFEXITED(status), WEXITSTATUS(status),
WIFSIGNALED(status), WTERMSIG(status));
}
}
if (status == 0) {
figL.bitmap_waiting = true;
p->broken = false;
} else {
// remove temporary files
char tmp[128];
sprintf(tmp, "%s/~lyxgs%d.ps",
system_tempdir.c_str(),
p->gspid);
unlink(tmp);
p->gspid = -1;
p->broken = true;
}
makeupdatelist(figL.bitmaps[i]);
gsQ.gsrunning--;
gsQ.runqueue();
break;
}
if (!pid) {
ProcessManager::pidwait *p = procMgr.pw, *prev = NULL;
while (p) {
if ((pid = waitpid(p->pid, &status, WNOHANG)) == p->pid
) {
// got a pid we were waiting for
if (lyxerr.debugging()) {
printf("Caught child pid of recompute routine %d\n",
pid);
}
if (prev) prev->next = p->next;
else procMgr.pw = p->next;
free(p);
break;
}
prev = p;
p = p->next;
}
}
if (lyxerr.debugging()) {
if (pid) lyxerr.print(LString("Caught child pid: ")
+ int(pid));
if (pid <= 0) /* jc: catching non expected SIGCHLD */
lyxerr.print(LString("Caught child pid: ")
+ int(wait(NULL)));
} else {
if (pid <= 0) {
wait(NULL);
}
}
}