wxMaxima
Loading...
Searching...
No Matches
MaximaProcessManager.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
38#ifndef MAXIMAPROCESSMANAGER_H
39#define MAXIMAPROCESSMANAGER_H
40
41#include <wx/string.h>
42
43class wxMaxima;
44class wxSocketEvent;
45class wxProcessEvent;
46class wxThreadEvent;
47class wxCommandEvent;
48
55{
56public:
57 explicit MaximaProcessManager(wxMaxima &wxm) : m_wxMaxima(wxm) {}
58
61 static void RegisterChildMaxima(long pid);
62
65 static void UnregisterChildMaxima(long pid);
66
74 static void KillAllChildMaximas();
75
80 static void SetupTerminationHandlers();
81
84 bool StartServer();
85
87 void ServerEvent(wxSocketEvent &event);
88
91 void OnMaximaConnect();
92
97 bool StartMaxima(bool force = false);
98
100 void KillMaxima(bool logMessage = true);
101
104 void OnMaximaClose();
107 void OnMaximaClose(wxProcessEvent &event);
108
111 void MaximaEvent(wxThreadEvent &event);
112
121 bool WriteToMaximaStdin(const wxString &line);
122
124 void Interrupt(wxCommandEvent &event);
125
128 void GnuplotCommandName(wxString gnuplot);
129
132 void OnGnuplotQueryTerminals(wxProcessEvent &event);
133
135 void OnGnuplotClose(wxProcessEvent &event);
136
137private:
140 wxMaxima &m_wxMaxima;
150 bool m_inMaximaEvent = false;
151};
152
153#endif // MAXIMAPROCESSMANAGER_H
The Maxima process/socket lifecycle extracted from the wxMaxima god class.
Definition: MaximaProcessManager.h:55
void ServerEvent(wxSocketEvent &event)
Handles a socket event on the server: on a connection, accepts it.
Definition: MaximaProcessManager.cpp:128
bool StartServer()
Opens the local socket server Maxima connects back to. Returns false if no server could be created.
Definition: MaximaProcessManager.cpp:173
void OnMaximaConnect()
Accepts Maxima's connection to our server socket, wires up the data stream and kicks off the initial ...
Definition: MaximaProcessManager.cpp:140
void OnGnuplotClose(wxProcessEvent &event)
wxEVT_END_PROCESS handler for the gnuplot subprocess: notes it has closed.
Definition: MaximaProcessManager.cpp:985
static void RegisterChildMaxima(long pid)
Remember a running child Maxima's (group-leader) PID so a signal/crash handler can kill it....
Definition: MaximaProcessManager.cpp:68
static void UnregisterChildMaxima(long pid)
Forget a child Maxima's PID once we have taken it down ourselves. Async-signal-safe; no-op on Windows...
Definition: MaximaProcessManager.cpp:83
static void KillAllChildMaximas()
SIGKILL every child Maxima we still have registered.
Definition: MaximaProcessManager.cpp:98
void KillMaxima(bool logMessage=true)
Kills the Maxima process (and cleans up its temp files / registered PID).
Definition: MaximaProcessManager.cpp:381
void Interrupt(wxCommandEvent &event)
Sends the running Maxima an interrupt (Ctrl+G / the interrupt button).
Definition: MaximaProcessManager.cpp:792
bool StartMaxima(bool force=false)
(Re)starts the Maxima process (and its server socket) if needed.
Definition: MaximaProcessManager.cpp:230
static void SetupTerminationHandlers()
Install the SIGTERM/SIGINT/SIGHUP handlers that run KillAllChildMaximas() so a child Maxima is not or...
Definition: MaximaProcessManager.cpp:113
void OnMaximaClose()
Reacts to the Maxima process having exited (reports it and, unless we closed it on purpose,...
Definition: MaximaProcessManager.cpp:526
void MaximaEvent(wxThreadEvent &event)
The EVT_MAXIMA handler: classifies each chunk Maxima sent over the socket and hands it to the matchin...
Definition: MaximaProcessManager.cpp:644
void OnGnuplotQueryTerminals(wxProcessEvent &event)
wxEVT_END_PROCESS handler for the gnuplot terminal-query subprocess: reads which terminals gnuplot su...
Definition: MaximaProcessManager.cpp:923
bool WriteToMaximaStdin(const wxString &line)
Writes one line of input to the Maxima process's stdin.
Definition: MaximaProcessManager.cpp:610
void GnuplotCommandName(wxString gnuplot)
Resolves the gnuplot executable path and (re)starts a background query of the graphics terminals it s...
Definition: MaximaProcessManager.cpp:991
Definition: wxMaxima.h:75