Skip to content

Instantly share code, notes, and snippets.

@tonycoz
Created November 16, 2023 01:07
Show Gist options
  • Save tonycoz/7ae969a9da084bfed71d888b74841931 to your computer and use it in GitHub Desktop.
Save tonycoz/7ae969a9da084bfed71d888b74841931 to your computer and use it in GitHub Desktop.
newlocale_loop.c
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
char psstr[40];
pid_t p = getpid();
snprintf(psstr, sizeof(psstr), "ps -l -p %ld", (long)p);
for (int i = 0; i < 1000000; ++i) {
if (i % 100000 == 0)
system(psstr);
locale_t l1 = newlocale(LC_ALL_MASK, "en_AU.UTF-8", (locale_t)0);
//locale_t old = uselocale(l1);
//uselocale(old);
freelocale(l1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment