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
+21-16Lines changed: 21 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,27 +138,32 @@ Each PEB interactive Perl script must have its own event loop waiting constantly
138
138
139
139
Please note that interactive Perl scripts are not supported by the Windows builds of PEB.
140
140
141
-
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.
141
+
PEB interactive Perl script should also have the following features:
142
142
143
-
When PEB is closing, it sends the ``SIGTERM`` signal to all interactive scripts 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:
143
+
***No buffering**
144
+
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.
144
145
145
-
```perl
146
-
$SIG{TERM} = sub {
147
-
# your shutdown code goes here...
148
-
exit();
149
-
};
150
-
```
146
+
***SIGTERM handling**
147
+
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:
151
148
152
-
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:
149
+
```perl
150
+
$SIG{TERM} = sub {
151
+
# your shutdown code goes here...
152
+
exit();
153
+
};
154
+
```
153
155
154
-
```perl
155
-
print"output string"or shutdown_procedure();
156
+
***Failsafe print**
157
+
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:
156
158
157
-
subshutdown_procedure {
158
-
# your shutdown code goes here...
159
-
exit();
160
-
}
161
-
```
159
+
```perl
160
+
print"output string"or shutdown_procedure();
161
+
162
+
subshutdown_procedure {
163
+
# your shutdown code goes here...
164
+
exit();
165
+
}
166
+
```
162
167
163
168
The following code shows how to start an interactive Perl script right after a local page is loaded:
0 commit comments