Skip to content

Commit

Permalink
test compilation windows
Browse files Browse the repository at this point in the history
  • Loading branch information
GillesDuvert committed Aug 5, 2024
1 parent 6ec8750 commit 803e1a9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/dinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ void SignalChildHandler(int)
{
// std::cout<<"signalOnCommandReturn was "<<signalOnCommandReturn<<std::endl;
signalOnCommandReturn=true;
signal(SIGUSR1,SignalChildHandler);
signal(GDL_SIGUSR1,SignalChildHandler);
}
string DInterpreter::GetLine()
{
Expand Down Expand Up @@ -1839,9 +1839,9 @@ RetCode DInterpreter::InterpreterLoop(const string& startup,
RunDelTree();
} else {
DInterpreter::CommandCode ret = ExecuteLine();
if (signalOnCommandReturn) { //cout is NOT a tty. We just send SIGUSR2 to parent
if (signalOnCommandReturn) { //cout is NOT a tty. We just send GDL_SIGUSR2 to parent
signalOnCommandReturn = false;
kill(getppid(), SIGUSR2);
kill(getppid(), GDL_SIGUSR2);
// std::cout<<"signalOnCommandReturn is now "<<signalOnCommandReturn<<std::endl;
}
// stop stepping when at main level
Expand Down
8 changes: 8 additions & 0 deletions src/dinterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
#include <fstream>
#include <csignal>

#if defined(_WIN32) && !defined(__CYGWIN__)
#define GDL_SIGUSR1 SIGABRT //working replacement avoidng changing code?
#define GDL_SIGUSR2 SIGILL
#else
#define GDL_SIGUSR1 SIGUSR1
#define GDL_SIGUSR2 SIGUSR2
#endif

#include <cfenv>

#include "GDLLexer.hpp"
Expand Down
8 changes: 4 additions & 4 deletions src/gdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,15 +562,15 @@ int main(int argc, char *argv[])
signal(SIGINT, ControlCHandler);

if (iAmMaster) {
signal(SIGUSR1,SIG_IGN);
signal(SIGUSR2,SIG_IGN);
signal(GDL_SIGUSR1,SIG_IGN);
signal(GDL_SIGUSR2,SIG_IGN);
signal(SIGCHLD,SIG_IGN); //end subprocess is by sending it 'EXIT'.
//This should avoid zombies after a IDL_IDLBridge::Cleanup for example.
// but we do not trap a subprocess crashing, which may be desirable!
}
else {
signal(SIGUSR1,SignalChildHandler);
signal(SIGUSR2,SIG_IGN);
signal(GDL_SIGUSR1,SignalChildHandler);
signal(GDL_SIGUSR2,SIG_IGN);
}

// must be after !cpu initialisation
Expand Down
14 changes: 7 additions & 7 deletions src/gdl2gdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ static void ChildSignalHandler(int sig, siginfo_t *siginfo, void *context) {
int WriteToChild(EnvT* e, DLong* id, const std::string & command, bool nowait = true) {
sigset_t sigmask;
sigemptyset(&sigmask);
sigaddset(&sigmask, SIGUSR2);
// sigaddset(&sigmask, SIGCHLD);
sigaddset(&sigmask, GDL_SIGUSR2);
// sigaddset(&sigmask, GDL_SIGCHLD);
//will trigger signalhandler
struct sigaction siga;
memset(&siga, 0, sizeof (struct sigaction)); //no complaints by Valgrind
Expand All @@ -74,13 +74,13 @@ int WriteToChild(EnvT* e, DLong* id, const std::string & command, bool nowait =
pid_t pid=id[2];
// should start with no error
g2gListOfSubprocesses.at(pid).second = "";
if (sigaction(SIGUSR2, &siga, NULL) != 0) {
if (sigaction(GDL_SIGUSR2, &siga, NULL) != 0) {
g2gListOfSubprocesses.at(pid).first = 3;
g2gListOfSubprocesses.at(pid).second = "Error in WriteToChild(), problem with sigaction:" + std::string(strerror(errno));
return 0;
}
auto l = command.length();
kill(id[2], SIGUSR1); //ask for a SIGUSR2 when returned
kill(id[2], GDL_SIGUSR1); //ask for a GDL_SIGUSR2 when returned
g2gListOfSubprocesses.at(pid).first = 1;
int status = write(id[1], command.c_str(), l);
if (status != l) {
Expand Down Expand Up @@ -257,7 +257,7 @@ namespace lib {
memcpy((char*) (mapAddress) + offset, p1->DataAddr(), nbytes);
msync(mapAddress, nbytes, MS_SYNC);
munmap(mapAddress, nbytes + offset); //unmap
// kill(getppid(), SIGUSR2); //respond to master: done
// kill(getppid(), GDL_SIGUSR2); //respond to master: done
}

//master: var=gmem_getvar(id,name)
Expand Down Expand Up @@ -474,7 +474,7 @@ namespace lib {
}
memcpy(var->DataAddr(), (char*) (mapAddress) + offset, nbytes);
munmap(mapAddress, length); //unmap
// kill(getppid(), SIGUSR2); //respond to master: done
// kill(getppid(), GDL_SIGUSR2); //respond to master: done
return var;
}

Expand Down Expand Up @@ -630,7 +630,7 @@ namespace lib {


if (g2gListOfSubprocesses.at(pid).first == 1) { //interrupt the process
kill((*triplet)[2], SIGUSR2);
kill((*triplet)[2], GDL_SIGUSR2);
g2gListOfSubprocesses.at(pid).first = 2; //aborted
HandleObjectsCallbacks(); //callback must be called
}
Expand Down

0 comments on commit 803e1a9

Please sign in to comment.