- Subject: [slang-users] Send a signal to a running process?
- From: Morten Bo Johansen <mbj@xxxxxxxxxxx>
- Date: Sun, 27 Mar 2016 14:27:36 +0200
Hi,
When writing a groff document, I would like to have the
rendered document displayed in a constantly open pdf-viewer and
by the press of a key to have the display in the pdf-viewer
updated with the changes in the jed buffer.
With the code I have written it works for some pdf-viewers
while others have some quirks that need to be addressed. For
instance, mupdf, wants to have a SIGHUP signal sent to it in
order for the display to be updated. So the question is, how
can I send a SIGHUP to the instance of mupdf that is associated
with the jed buffer when pressing the key to update the
display?
The functiom "view_document" and supporting functions look like this:
private variable pdfviewer_pid;
private define show_pdfviewer_error (pid, error)
{
flush (strtrim (error));
}
private define pdfviewer_signal_handler (pid, flags, status)
{
ifnot (flags == 1) % if proces is no longer running
__uninitialize (&pdfviewer_pid);
}
%% View current buffer dynamically in a pdf-viewer. Display in
%% pdf-viewer is dynamically updated with changes in buffer upon
%% pressing a key, with no need to save the file associated
%% with the buffer in between.
define view_document ()
{
variable tmpfile = make_tmp_file ("/tmp/viewmomdoc");
variable pdf_file = dircat ("/tmp", path_sans_extname (whatbuf ()) + ".pdf");
variable docstr = "";
push_spot_bob ();
push_mark_eob ();
() = write_region_to_file (docstr, tmpfile);
pop_spot ();
() = system (strcat ("pdfmom ", tmpfile, ">", pdf_file));
ifnot (__is_initialized (&pdfviewer_pid))
{
pdfviewer_pid = open_process ("mupdf", pdf_file, 1);
set_process (pdfviewer_pid, "output", &show_pdfviewer_error);
set_process (pdfviewer_pid, "signal", &pdfviewer_signal_handler);
process_query_at_exit (pdfviewer_pid, 0);
}
else
% this is of course not tenable, but illustrates what I want
() = system ("kill -hup $(pidof /usr/lib/mupdf/mupdf-x11)");
}
Thanks,
Morten
_______________________________________________
For list information, visit <http://jedsoft.org/slang/mailinglists.html>.
[2016 date index]
[2016 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]