Created
December 23, 2019 15:26
-
-
Save cirocosta/fd71960ff0ec48941869d0bc96981880 to your computer and use it in GitHub Desktop.
setenv-sample.c
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 <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