You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/SETTINGS.md
+5-12Lines changed: 5 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -157,18 +157,10 @@ A PEB interactive Perl script should have the following features:
157
157
***No buffering**
158
158
PEB interactive scripts should have ``$|=1;`` among their first lines to disable the built-in buffering of the Perl interpreter, which prevents any output before the script has ended.
159
159
160
-
***SIGTERM handling**
161
-
PEB sends the ``SIGTERM`` signal to all interactive scripts on exit for a graceful shutdown and to prevent them from becoming zombie processes. All interactive scripts must exit in 3 seconds after the ``SIGTERM`` signal is given by PEB. All unresponsive scripts are killed before PEB exits. The ``SIGTERM`` signal may be handled by any interactive script for a graceful shutdown using the following code:
162
-
163
-
```perl
164
-
$SIG{TERM} = sub {
165
-
# your shutdown code goes here...
166
-
exit();
167
-
};
168
-
```
169
-
170
160
***Failsafe print**
171
-
If a PEB instance crashes, it can still leave its interactive scripts as zombie processes consuming large amounts of memory. To prevent this scenario, all interactive scripts should test for a successful ``print`` on the STDOUT. This could be implemented using the following code:
161
+
Failsafe print is necessary for a graceful shutdown of Perl scripts on normal PEB exit and when PEB unexpectedly crashes. PEB closes the STDOUT and STDERR channels of all running Perl scripts when the close button is pressed - they must exit in 3 seconds or any unresponsive scripts are killed.
162
+
163
+
Failsafe print could be implemented using the following code:
172
164
173
165
```perl
174
166
print"output string"or shutdown_procedure();
@@ -198,6 +190,7 @@ The following code shows how to start a PEB interactive Perl script right after
var container =document.getElementById('interactive-script-output');
203
196
container.innerText= stdout;
@@ -216,7 +209,7 @@ The following code shows how to start a PEB interactive Perl script right after
216
209
</html>
217
210
```
218
211
219
-
The [index.htm](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/index.html)page of the demo package demonstrates how to start one script in two instances immediately after local page is loaded.
212
+
The [index.htm of the demo package](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/index.html)shows how to start one Perl script in two instances right after the PEB index page is loaded.
220
213
221
214
The [interactive.pl](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/perl/interactive.pl) script of the demo package is an example of a Perl interactive script for PEB.
0 commit comments