Skip to content

Instantly share code, notes, and snippets.

@quickyu
quickyu / thread-and-signal.c
Created August 31, 2017 10:40 — forked from dram/thread-and-signal.c
Using signal and `pthread_kill` to terminate specific thread. `pthread_sigmask` can be used in thread to block signal temporarily.
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <pthread.h>
#include <time.h>
static void debug(const char *msg) {
time_t t = time(NULL);
fprintf(stderr, "%s%s\n\n", ctime(&t), msg);
@quickyu
quickyu / recvRawEth.c
Created August 30, 2017 02:42 — forked from austinmarton/recvRawEth.c
Receive raw Ethernet frames in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/ip.h>
@quickyu
quickyu / sendRawEth.c
Created August 30, 2017 02:42 — forked from austinmarton/sendRawEth.c
Send a raw Ethernet frame in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>