Created
July 10, 2018 07:32
-
-
Save ridiculousfish/0f7fb0f0ea2c1174f2aeadebebe9ddf0 to your computer and use it in GitHub Desktop.
burn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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