Skip to content

Instantly share code, notes, and snippets.

@ridiculousfish
Created July 10, 2018 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ridiculousfish/0f7fb0f0ea2c1174f2aeadebebe9ddf0 to your computer and use it in GitHub Desktop.
Save ridiculousfish/0f7fb0f0ea2c1174f2aeadebebe9ddf0 to your computer and use it in GitHub Desktop.
burn
#include <string>
#include <sys/types.h>
#include <pwd.h>
#include <uuid/uuid.h>
#include <vector>
#include <thread>
static size_t burn() {
size_t ret = 0;
setpwent();
struct passwd *pw;
while ((pw = getpwent()) != NULL) {
const std::string pw_name_str = pw->pw_name;
ret += pw_name_str.size();
}
endpwent();
return ret;
}
int main(void) {
std::vector<std::thread> threads;
for (size_t i=0; i < 1000; i++) {
threads.push_back(std::thread(burn));
}
for (auto &t : threads) {
t.join();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment