Friday, September 16, 2016
Trapping signals in Docker containers Have you ever stopped a Docker container?
As an example, let’s run the following application (program.js) inside a container and examine signal handlers.
'use strict';
var http = require('http');
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(3000, '0.0.0.0');
console.log('server started');
var signals = {
'SIGINT': 2,
'SIGTERM': 15
};
function shutdown(signal, value) {
server.close(function () {
console.log('server stopped by ' + signal);
process.exit(128 + value);
});
}
Object.keys(signals).forEach(function (signal) {
process.on(signal, function () {
shutdown(signal, signals[signal]);
});
});
Here we create an HTTP-server that listens on port 3000 and setup two signal handlers for SIGINT and SIGTERM. When handled, the following message will be printed to stdout: `server stopped by [SIGNAL]`.
forces to decode the most probable coded sequence that succeeds the verification of the outer code
| /* |
| RFSniffer |
| Usage: ./RFSniffer [ |
| [] = optional |
| Hacked from http://code.google.com/p/rc-switch/ |
| by @justy to provide a handy RF code sniffer |
| */ |
|
|
| #include "../rc-switch/RCSwitch.h" |
| #include <stdlib.h> |
| #include <stdio.h> |
| |
| |
| RCSwitch mySwitch; |
| |
|
|
|
|
| int main(int argc, char *argv[]) { |
| |
| // This pin is not the first pin on the RPi GPIO header! |
| // Consult https://projects.drogon.net/raspberry-pi/wiringpi/pins/ |
| // for more information. |
| int PIN = 2; |
| |
| if(wiringPiSetup() == -1) { |
| printf("wiringPiSetup failed, exiting..."); |
| return 0; |
| } |
|
|
| int pulseLength = 0; |
| if (argv[1] != NULL) pulseLength = atoi(argv[1]); |
|
|
| mySwitch = RCSwitch(); |
| if (pulseLength != 0) mySwitch.setPulseLength(pulseLength); |
| mySwitch.enableReceive(PIN); // Receiver on interrupt 0 => that is pin #2 |
| |
| |
| while(1) { |
| |
| if (mySwitch.available()) { |
| |
| int value = mySwitch.getReceivedValue(); |
| |
| if (value == 0) { |
| printf("Unknown encoding\n"); |
| } else { |
| |
| printf("Received %i\n", mySwitch.getReceivedValue() ); |
| } |
| |
| mySwitch.resetAvailable(); | |||
| |
| } |
| |
| |
| } |
|
|
| exit(0); |
|
|
|
|
https://github.com/ninjablocks/433Utils/blob/master/RPi_utils/RFSniffer.cpp
Subscribe to:
Comments (Atom)
Gd morning Ambassador @EmbaixadaRusPt And today TAP INTEL the summary of the emails @PJudiciaria is searching
https://www.srslegal.pt/pt/area-reservada/login/ https://www.publico.pt/2023/06/14/politica/noticia/inquerito-tap-exsecretario-estado-infra...