Skip to content

Instantly share code, notes, and snippets.

@cirocosta
Created December 23, 2019 15:26
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 cirocosta/fd71960ff0ec48941869d0bc96981880 to your computer and use it in GitHub Desktop.
Save cirocosta/fd71960ff0ec48941869d0bc96981880 to your computer and use it in GitHub Desktop.
setenv-sample.c
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void handle_sig(int sig) {}
void wait_a_bit() {
if (signal(SIGINT, handle_sig) == SIG_ERR) {
perror("signal");
exit(1);
}
pause();
}
int main(int argc, char** argv)
{
wait_a_bit();
if (!~setenv("foo", "bar", 0)) {
perror("setenv");
return 1;
}
wait_a_bit();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment