Skip to content

Instantly share code, notes, and snippets.

@chaitanyav
chaitanyav / tee.c
Last active December 13, 2015 18:49
/*
* Author: NagaChaitanya Vellanki
*
* tee - read from standard input and write to standard output and files
*
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@chaitanyav
chaitanyav / yes.c
Last active December 13, 2015 18:49
/*
* Author: Nagachaitanya Vellanki
*
* yes - output a string repeatedly until killed
*/
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdlib.h>
/*
* Author: NagaChaitanya Vellanki
*
* whoami - print effective user id
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
/*
*
* Author: NagaChaitanya Vellanki
*
*
* printenv command implementation
*
*/
#include<stdio.h>
/*
*
* Author: NagaChaitanya Vellanki
*
*
* display environment variables
*
*/
#include<stdio.h>
#include<stdlib.h>
/*
*
* Author: NagaChaitanya Vellanki
*
*
* get or set or unset environment variables
* clean environment
* gcc -o get_set_env -Wall --pedantic get_set_env.c -D_SVID_SOURCE
*/
/*
* Author: NagaChaitanya Vellanki
*
* TRY/THROW/CATCH example
* Reference: http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html
* use gcc -E -P exception_handling_1.c to the output of the preprocessor
*/
#include <stdio.h>
#include <stdlib.h>
/*
* Author: NagaChaitanya Vellanki
*
* TRY/THROW/CATCH - example
* Reference: http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html
*
* use gcc -E -P exception_handling_2.c to the output of the preprocessor
*/
#include <stdio.h>
/*
* Author: NagaChaitanya Vellanki
*
* TRY/THROW/CATCH/FINALLY - example
* Reference: http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html
*
* use gcc -E -P exception_handling_3.c to see the result of the preprocessing
* step
*/
/*
*
* Author: NagaChaitanya Vellanki
*
*
* See Listing 7-1, chapter 4 of LPI book
*
* sample output:
*
* ./free_and_sbrk 1000 10240 1 1 1000