CONTENT
  • CHANGES
Szukaj
counter

#top Miscellaneous


code / ansic / misc

#top Makefile


Dla ułatwienia korzystania z przykładów został utworzony jeden zbiorczy plik Makefile kompilujący przykłady użycia poniżej wymienionych funkcji związanych różnymi niesklasyfikowanymi operacjami.

Poniższe pliki Makefile zakładają obecność wszystkich plików przykładów, w przypadku chęci kompilacji za pomocą Makefile tylko wybranego przykładu należy zakomentować w pliku Makefile ostatnią pozycję zawierającą listę wszystkich targetów do wykonania make: $(ABORT) ..., a następnie odkomentować powyżej komendę make zawierającą nazwę targetu dla bieżącego przykładu, np: w przypadku chęci kompilacji tylko przykładu abort należy zakomentować ostatnią pozycję rozpoczynającą się od make: $(ABORT) ... (wstawić na początku przed make znak #), a następnie odkomentować pozycję: #make: $(ABORT) (usunąć znak #).

#top Makefile (linux)


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_CLEARENV=1 -DHAVE_DAEMON=1 -DHAVE_ENVIRON=1 -DHAVE_GETOPT_LONG_ONLY=1 -DHAVE_GETRUSAGE=1 -DHAVE_ONEXIT=1 -DHAVE_UNSETENV_RESULT=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ABORT       = abort
ALARM       = alarm
ATEXIT1     = atexit1
ATEXIT2     = atexit2
CLEARENV    = clearenv
CONFSTR     = confstr
DAEMON      = daemon
ENVIRON     = environ
EXIT        = exit
EXIT_FAILURE= EXIT_FAILURE
EXIT_SUCCESS= EXIT_SUCCESS
GETENV      = getenv
GETOPT      = getopt
GETOPT_LONG = getopt_long
GETOPT_LONG_ONLY= getopt_long_only
GETRLIMIT   = getrlimit
GETRUSAGE   = getrusage
NANOSLEEP   = nanosleep
ON_EXIT1    = on_exit1
ON_EXIT2    = on_exit2
PATHCONF    = pathconf
PAUSE1      = pause1
PAUSE2      = pause2
PERROR      = perror
PUTENV      = putenv
SETENV      = setenv
SETRLIMIT   = setrlimit
SLEEP       = sleep
SYSCONF     = sysconf
UALARM1     = ualarm1
UALARM2     = ualarm2
UNSETENV    = unsetenv
USLEEP      = usleep



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ABORT)
#make: $(ALARM)
#make: $(ATEXIT1)
#make: $(ATEXIT2)
#make: $(CLEARENV)
#make: $(CONFSTR)
#make: $(DAEMON)
#make: $(ENVIRON)
#make: $(EXIT)
#make: $(EXIT_FAILURE)
#make: $(EXIT_SUCCESS)
#make: $(GETENV)
#make: $(GETOPT)
#make: $(GETOPT_LONG)
#make: $(GETOPT_LONG_ONLY)
#make: $(GETRLIMIT)
#make: $(GETRUSAGE)
#make: $(NANOSLEEP)
#make: $(ON_EXIT1)
#make: $(ON_EXIT2)
#make: $(PATHCONF)
#make: $(PAUSE1)
#make: $(PAUSE2)
#make: $(PERROR)
#make: $(PUTENV)
#make: $(SETENV)
#make: $(SETRLIMIT)
#make: $(SLEEP)
#make: $(SYSCONF)
#make: $(UALARM1)
#make: $(UALARM2)
#make: $(UNSETENV)
#make: $(USLEEP)
make: $(ABORT) $(ALARM) $(ATEXIT1) $(ATEXIT2) $(CLEARENV) $(CONFSTR) $(DAEMON) $(ENVIRON) $(EXIT) $(EXIT_FAILURE) $(EXIT_SUCCESS) $(GETENV) $(GETOPT) $(GETOPT_LONG) $(GETOPT_LONG_ONLY) $(GETRLIMIT) $(GETRUSAGE) $(NANOSLEEP) $(ON_EXIT1) $(ON_EXIT2) $(PATHCONF) $(PAUSE1) $(PAUSE2) $(PERROR) $(PUTENV) $(SETENV) $(SETRLIMIT) $(SLEEP) $(SYSCONF) $(UALARM1) $(UALARM2) $(UNSETENV) $(USLEEP)



$(ABORT): $(ABORT).o
	$(GCC) -o $(ABORT) obj/$(ABORT).o $(LDFLAGS)
$(ABORT).o:
	$(GCC) -o obj/$(ABORT).o -c $(ABORT).c $(CFLAGS)

$(ALARM): $(ALARM).o
	$(GCC) -o $(ALARM) obj/$(ALARM).o $(LDFLAGS)
$(ALARM).o:
	$(GCC) -o obj/$(ALARM).o -c $(ALARM).c $(CFLAGS)

$(ATEXIT1): $(ATEXIT1).o
	$(GCC) -o $(ATEXIT1) obj/$(ATEXIT1).o $(LDFLAGS)
$(ATEXIT1).o:
	$(GCC) -o obj/$(ATEXIT1).o -c $(ATEXIT1).c $(CFLAGS)

$(ATEXIT2): $(ATEXIT2).o
	$(GCC) -o $(ATEXIT2) obj/$(ATEXIT2).o $(LDFLAGS)
$(ATEXIT2).o:
	$(GCC) -o obj/$(ATEXIT2).o -c $(ATEXIT2).c $(CFLAGS)

$(CLEARENV): $(CLEARENV).o
	$(GCC) -o $(CLEARENV) obj/$(CLEARENV).o $(LDFLAGS)
$(CLEARENV).o:
	$(GCC) -o obj/$(CLEARENV).o -c $(CLEARENV).c $(CFLAGS)

$(CONFSTR): $(CONFSTR).o
	$(GCC) -o $(CONFSTR) obj/$(CONFSTR).o $(LDFLAGS)
$(CONFSTR).o:
	$(GCC) -o obj/$(CONFSTR).o -c $(CONFSTR).c $(CFLAGS)

$(DAEMON): $(DAEMON).o
	$(GCC) -o $(DAEMON) obj/$(DAEMON).o $(LDFLAGS)
$(DAEMON).o:
	$(GCC) -o obj/$(DAEMON).o -c $(DAEMON).c $(CFLAGS)

$(ENVIRON): $(ENVIRON).o
	$(GCC) -o $(ENVIRON) obj/$(ENVIRON).o $(LDFLAGS)
$(ENVIRON).o:
	$(GCC) -o obj/$(ENVIRON).o -c $(ENVIRON).c $(CFLAGS)

$(EXIT): $(EXIT).o
	$(GCC) -o $(EXIT) obj/$(EXIT).o $(LDFLAGS)
$(EXIT).o:
	$(GCC) -o obj/$(EXIT).o -c $(EXIT).c $(CFLAGS)

$(EXIT_FAILURE): $(EXIT_FAILURE).o
	$(GCC) -o $(EXIT_FAILURE) obj/$(EXIT_FAILURE).o $(LDFLAGS)
$(EXIT_FAILURE).o:
	$(GCC) -o obj/$(EXIT_FAILURE).o -c $(EXIT_FAILURE).c $(CFLAGS)

$(EXIT_SUCCESS): $(EXIT_SUCCESS).o
	$(GCC) -o $(EXIT_SUCCESS) obj/$(EXIT_SUCCESS).o $(LDFLAGS)
$(EXIT_SUCCESS).o:
	$(GCC) -o obj/$(EXIT_SUCCESS).o -c $(EXIT_SUCCESS).c $(CFLAGS)

$(GETENV): $(GETENV).o
	$(GCC) -o $(GETENV) obj/$(GETENV).o $(LDFLAGS)
$(GETENV).o:
	$(GCC) -o obj/$(GETENV).o -c $(GETENV).c $(CFLAGS)

$(GETOPT): $(GETOPT).o
	$(GCC) -o $(GETOPT) obj/$(GETOPT).o $(LDFLAGS)
$(GETOPT).o:
	$(GCC) -o obj/$(GETOPT).o -c $(GETOPT).c $(CFLAGS)

$(GETOPT_LONG): $(GETOPT_LONG).o
	$(GCC) -o $(GETOPT_LONG) obj/$(GETOPT_LONG).o $(LDFLAGS)
$(GETOPT_LONG).o:
	$(GCC) -o obj/$(GETOPT_LONG).o -c $(GETOPT_LONG).c $(CFLAGS)

$(GETOPT_LONG_ONLY): $(GETOPT_LONG_ONLY).o
	$(GCC) -o $(GETOPT_LONG_ONLY) obj/$(GETOPT_LONG_ONLY).o $(LDFLAGS)
$(GETOPT_LONG_ONLY).o:
	$(GCC) -o obj/$(GETOPT_LONG_ONLY).o -c $(GETOPT_LONG_ONLY).c $(CFLAGS)

$(GETRLIMIT): $(GETRLIMIT).o
	$(GCC) -o $(GETRLIMIT) obj/$(GETRLIMIT).o $(LDFLAGS)
$(GETRLIMIT).o:
	$(GCC) -o obj/$(GETRLIMIT).o -c $(GETRLIMIT).c $(CFLAGS)

$(GETRUSAGE): $(GETRUSAGE).o
	$(GCC) -o $(GETRUSAGE) obj/$(GETRUSAGE).o $(LDFLAGS)
$(GETRUSAGE).o:
	$(GCC) -o obj/$(GETRUSAGE).o -c $(GETRUSAGE).c $(CFLAGS)

$(NANOSLEEP): $(NANOSLEEP).o
	$(GCC) -o $(NANOSLEEP) obj/$(NANOSLEEP).o $(LDFLAGS)
$(NANOSLEEP).o:
	$(GCC) -o obj/$(NANOSLEEP).o -c $(NANOSLEEP).c $(CFLAGS)

$(ON_EXIT1): $(ON_EXIT1).o
	$(GCC) -o $(ON_EXIT1) obj/$(ON_EXIT1).o $(LDFLAGS)
$(ON_EXIT1).o:
	$(GCC) -o obj/$(ON_EXIT1).o -c $(ON_EXIT1).c $(CFLAGS)

$(ON_EXIT2): $(ON_EXIT2).o
	$(GCC) -o $(ON_EXIT2) obj/$(ON_EXIT2).o $(LDFLAGS)
$(ON_EXIT2).o:
	$(GCC) -o obj/$(ON_EXIT2).o -c $(ON_EXIT2).c $(CFLAGS)

$(PATHCONF): $(PATHCONF).o
	$(GCC) -o $(PATHCONF) obj/$(PATHCONF).o $(LDFLAGS)
$(PATHCONF).o:
	$(GCC) -o obj/$(PATHCONF).o -c $(PATHCONF).c $(CFLAGS)

$(PAUSE1): $(PAUSE1).o
	$(GCC) -o $(PAUSE1) obj/$(PAUSE1).o $(LDFLAGS)
$(PAUSE1).o:
	$(GCC) -o obj/$(PAUSE1).o -c $(PAUSE1).c $(CFLAGS)

$(PAUSE2): $(PAUSE2).o
	$(GCC) -o $(PAUSE2) obj/$(PAUSE2).o $(LDFLAGS)
$(PAUSE2).o:
	$(GCC) -o obj/$(PAUSE2).o -c $(PAUSE2).c $(CFLAGS)

$(PERROR): $(PERROR).o
	$(GCC) -o $(PERROR) obj/$(PERROR).o $(LDFLAGS)
$(PERROR).o:
	$(GCC) -o obj/$(PERROR).o -c $(PERROR).c $(CFLAGS)

$(PUTENV): $(PUTENV).o
	$(GCC) -o $(PUTENV) obj/$(PUTENV).o $(LDFLAGS)
$(PUTENV).o:
	$(GCC) -o obj/$(PUTENV).o -c $(PUTENV).c $(CFLAGS)

$(SETENV): $(SETENV).o
	$(GCC) -o $(SETENV) obj/$(SETENV).o $(LDFLAGS)
$(SETENV).o:
	$(GCC) -o obj/$(SETENV).o -c $(SETENV).c $(CFLAGS)

$(SETRLIMIT): $(SETRLIMIT).o
	$(GCC) -o $(SETRLIMIT) obj/$(SETRLIMIT).o $(LDFLAGS)
$(SETRLIMIT).o:
	$(GCC) -o obj/$(SETRLIMIT).o -c $(SETRLIMIT).c $(CFLAGS)

$(SLEEP): $(SLEEP).o
	$(GCC) -o $(SLEEP) obj/$(SLEEP).o $(LDFLAGS)
$(SLEEP).o:
	$(GCC) -o obj/$(SLEEP).o -c $(SLEEP).c $(CFLAGS)

$(SYSCONF): $(SYSCONF).o
	$(GCC) -o $(SYSCONF) obj/$(SYSCONF).o $(LDFLAGS)
$(SYSCONF).o:
	$(GCC) -o obj/$(SYSCONF).o -c $(SYSCONF).c $(CFLAGS)

$(UALARM1): $(UALARM1).o
	$(GCC) -o $(UALARM1) obj/$(UALARM1).o $(LDFLAGS)
$(UALARM1).o:
	$(GCC) -o obj/$(UALARM1).o -c $(UALARM1).c $(CFLAGS)

$(UALARM2): $(UALARM2).o
	$(GCC) -o $(UALARM2) obj/$(UALARM2).o $(LDFLAGS)
$(UALARM2).o:
	$(GCC) -o obj/$(UALARM2).o -c $(UALARM2).c $(CFLAGS)

$(UNSETENV): $(UNSETENV).o
	$(GCC) -o $(UNSETENV) obj/$(UNSETENV).o $(LDFLAGS)
$(UNSETENV).o:
	$(GCC) -o obj/$(UNSETENV).o -c $(UNSETENV).c $(CFLAGS)

$(USLEEP): $(USLEEP).o
	$(GCC) -o $(USLEEP) obj/$(USLEEP).o $(LDFLAGS)
$(USLEEP).o:
	$(GCC) -o obj/$(USLEEP).o -c $(USLEEP).c $(CFLAGS)



#top Makefile.obsd


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_DAEMON=1 -DHAVE_GETOPT_LONG_ONLY=1 -DHAVE_GETRUSAGE=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ABORT       = abort
ALARM       = alarm
ATEXIT1     = atexit1
ATEXIT2     = atexit2
CLEARENV    = clearenv
CONFSTR     = confstr
DAEMON      = daemon
ENVIRON     = environ
EXIT        = exit
EXIT_FAILURE= EXIT_FAILURE
EXIT_SUCCESS= EXIT_SUCCESS
GETENV      = getenv
GETOPT      = getopt
GETOPT_LONG = getopt_long
GETOPT_LONG_ONLY= getopt_long_only
GETRLIMIT   = getrlimit
GETRUSAGE   = getrusage
NANOSLEEP   = nanosleep
ON_EXIT1    = on_exit1
ON_EXIT2    = on_exit2
PATHCONF    = pathconf
PAUSE1      = pause1
PAUSE2      = pause2
PERROR      = perror
PUTENV      = putenv
SETENV      = setenv
SETRLIMIT   = setrlimit
SLEEP       = sleep
SYSCONF     = sysconf
UALARM1     = ualarm1
UALARM2     = ualarm2
UNSETENV    = unsetenv
USLEEP      = usleep



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ABORT)
#make: $(ALARM)
#make: $(ATEXIT1)
#make: $(ATEXIT2)
#make: $(CLEARENV)
#make: $(CONFSTR)
#make: $(DAEMON)
#make: $(ENVIRON)
#make: $(EXIT)
#make: $(EXIT_FAILURE)
#make: $(EXIT_SUCCESS)
#make: $(GETENV)
#make: $(GETOPT)
#make: $(GETOPT_LONG)
#make: $(GETOPT_LONG_ONLY)
#make: $(GETRLIMIT)
#make: $(GETRUSAGE)
#make: $(NANOSLEEP)
#make: $(ON_EXIT1)
#make: $(ON_EXIT2)
#make: $(PATHCONF)
#make: $(PAUSE1)
#make: $(PAUSE2)
#make: $(PERROR)
#make: $(PUTENV)
#make: $(SETENV)
#make: $(SETRLIMIT)
#make: $(SLEEP)
#make: $(SYSCONF)
#make: $(UALARM1)
#make: $(UALARM2)
#make: $(UNSETENV)
#make: $(USLEEP)
make: $(ABORT) $(ALARM) $(ATEXIT1) $(ATEXIT2) $(CLEARENV) $(CONFSTR) $(DAEMON) $(ENVIRON) $(EXIT) $(EXIT_FAILURE) $(EXIT_SUCCESS) $(GETENV) $(GETOPT) $(GETOPT_LONG) $(GETOPT_LONG_ONLY) $(GETRLIMIT) $(GETRUSAGE) $(NANOSLEEP) $(ON_EXIT1) $(ON_EXIT2) $(PATHCONF) $(PAUSE1) $(PAUSE2) $(PERROR) $(PUTENV) $(SETENV) $(SETRLIMIT) $(SLEEP) $(SYSCONF) $(UALARM1) $(UALARM2) $(UNSETENV) $(USLEEP)



$(ABORT): $(ABORT).o
	$(GCC) -o $(ABORT) obj/$(ABORT).o $(LDFLAGS)
$(ABORT).o:
	$(GCC) -o obj/$(ABORT).o -c $(ABORT).c $(CFLAGS)

$(ALARM): $(ALARM).o
	$(GCC) -o $(ALARM) obj/$(ALARM).o $(LDFLAGS)
$(ALARM).o:
	$(GCC) -o obj/$(ALARM).o -c $(ALARM).c $(CFLAGS)

$(ATEXIT1): $(ATEXIT1).o
	$(GCC) -o $(ATEXIT1) obj/$(ATEXIT1).o $(LDFLAGS)
$(ATEXIT1).o:
	$(GCC) -o obj/$(ATEXIT1).o -c $(ATEXIT1).c $(CFLAGS)

$(ATEXIT2): $(ATEXIT2).o
	$(GCC) -o $(ATEXIT2) obj/$(ATEXIT2).o $(LDFLAGS)
$(ATEXIT2).o:
	$(GCC) -o obj/$(ATEXIT2).o -c $(ATEXIT2).c $(CFLAGS)

$(CLEARENV): $(CLEARENV).o
	$(GCC) -o $(CLEARENV) obj/$(CLEARENV).o $(LDFLAGS)
$(CLEARENV).o:
	$(GCC) -o obj/$(CLEARENV).o -c $(CLEARENV).c $(CFLAGS)

$(CONFSTR): $(CONFSTR).o
	$(GCC) -o $(CONFSTR) obj/$(CONFSTR).o $(LDFLAGS)
$(CONFSTR).o:
	$(GCC) -o obj/$(CONFSTR).o -c $(CONFSTR).c $(CFLAGS)

$(DAEMON): $(DAEMON).o
	$(GCC) -o $(DAEMON) obj/$(DAEMON).o $(LDFLAGS)
$(DAEMON).o:
	$(GCC) -o obj/$(DAEMON).o -c $(DAEMON).c $(CFLAGS)

$(ENVIRON): $(ENVIRON).o
	$(GCC) -o $(ENVIRON) obj/$(ENVIRON).o $(LDFLAGS)
$(ENVIRON).o:
	$(GCC) -o obj/$(ENVIRON).o -c $(ENVIRON).c $(CFLAGS)

$(EXIT): $(EXIT).o
	$(GCC) -o $(EXIT) obj/$(EXIT).o $(LDFLAGS)
$(EXIT).o:
	$(GCC) -o obj/$(EXIT).o -c $(EXIT).c $(CFLAGS)

$(EXIT_FAILURE): $(EXIT_FAILURE).o
	$(GCC) -o $(EXIT_FAILURE) obj/$(EXIT_FAILURE).o $(LDFLAGS)
$(EXIT_FAILURE).o:
	$(GCC) -o obj/$(EXIT_FAILURE).o -c $(EXIT_FAILURE).c $(CFLAGS)

$(EXIT_SUCCESS): $(EXIT_SUCCESS).o
	$(GCC) -o $(EXIT_SUCCESS) obj/$(EXIT_SUCCESS).o $(LDFLAGS)
$(EXIT_SUCCESS).o:
	$(GCC) -o obj/$(EXIT_SUCCESS).o -c $(EXIT_SUCCESS).c $(CFLAGS)

$(GETENV): $(GETENV).o
	$(GCC) -o $(GETENV) obj/$(GETENV).o $(LDFLAGS)
$(GETENV).o:
	$(GCC) -o obj/$(GETENV).o -c $(GETENV).c $(CFLAGS)

$(GETOPT): $(GETOPT).o
	$(GCC) -o $(GETOPT) obj/$(GETOPT).o $(LDFLAGS)
$(GETOPT).o:
	$(GCC) -o obj/$(GETOPT).o -c $(GETOPT).c $(CFLAGS)

$(GETOPT_LONG): $(GETOPT_LONG).o
	$(GCC) -o $(GETOPT_LONG) obj/$(GETOPT_LONG).o $(LDFLAGS)
$(GETOPT_LONG).o:
	$(GCC) -o obj/$(GETOPT_LONG).o -c $(GETOPT_LONG).c $(CFLAGS)

$(GETOPT_LONG_ONLY): $(GETOPT_LONG_ONLY).o
	$(GCC) -o $(GETOPT_LONG_ONLY) obj/$(GETOPT_LONG_ONLY).o $(LDFLAGS)
$(GETOPT_LONG_ONLY).o:
	$(GCC) -o obj/$(GETOPT_LONG_ONLY).o -c $(GETOPT_LONG_ONLY).c $(CFLAGS)

$(GETRLIMIT): $(GETRLIMIT).o
	$(GCC) -o $(GETRLIMIT) obj/$(GETRLIMIT).o $(LDFLAGS)
$(GETRLIMIT).o:
	$(GCC) -o obj/$(GETRLIMIT).o -c $(GETRLIMIT).c $(CFLAGS)

$(GETRUSAGE): $(GETRUSAGE).o
	$(GCC) -o $(GETRUSAGE) obj/$(GETRUSAGE).o $(LDFLAGS)
$(GETRUSAGE).o:
	$(GCC) -o obj/$(GETRUSAGE).o -c $(GETRUSAGE).c $(CFLAGS)

$(NANOSLEEP): $(NANOSLEEP).o
	$(GCC) -o $(NANOSLEEP) obj/$(NANOSLEEP).o $(LDFLAGS)
$(NANOSLEEP).o:
	$(GCC) -o obj/$(NANOSLEEP).o -c $(NANOSLEEP).c $(CFLAGS)

$(ON_EXIT1): $(ON_EXIT1).o
	$(GCC) -o $(ON_EXIT1) obj/$(ON_EXIT1).o $(LDFLAGS)
$(ON_EXIT1).o:
	$(GCC) -o obj/$(ON_EXIT1).o -c $(ON_EXIT1).c $(CFLAGS)

$(ON_EXIT2): $(ON_EXIT2).o
	$(GCC) -o $(ON_EXIT2) obj/$(ON_EXIT2).o $(LDFLAGS)
$(ON_EXIT2).o:
	$(GCC) -o obj/$(ON_EXIT2).o -c $(ON_EXIT2).c $(CFLAGS)

$(PATHCONF): $(PATHCONF).o
	$(GCC) -o $(PATHCONF) obj/$(PATHCONF).o $(LDFLAGS)
$(PATHCONF).o:
	$(GCC) -o obj/$(PATHCONF).o -c $(PATHCONF).c $(CFLAGS)

$(PAUSE1): $(PAUSE1).o
	$(GCC) -o $(PAUSE1) obj/$(PAUSE1).o $(LDFLAGS)
$(PAUSE1).o:
	$(GCC) -o obj/$(PAUSE1).o -c $(PAUSE1).c $(CFLAGS)

$(PAUSE2): $(PAUSE2).o
	$(GCC) -o $(PAUSE2) obj/$(PAUSE2).o $(LDFLAGS)
$(PAUSE2).o:
	$(GCC) -o obj/$(PAUSE2).o -c $(PAUSE2).c $(CFLAGS)

$(PERROR): $(PERROR).o
	$(GCC) -o $(PERROR) obj/$(PERROR).o $(LDFLAGS)
$(PERROR).o:
	$(GCC) -o obj/$(PERROR).o -c $(PERROR).c $(CFLAGS)

$(PUTENV): $(PUTENV).o
	$(GCC) -o $(PUTENV) obj/$(PUTENV).o $(LDFLAGS)
$(PUTENV).o:
	$(GCC) -o obj/$(PUTENV).o -c $(PUTENV).c $(CFLAGS)

$(SETENV): $(SETENV).o
	$(GCC) -o $(SETENV) obj/$(SETENV).o $(LDFLAGS)
$(SETENV).o:
	$(GCC) -o obj/$(SETENV).o -c $(SETENV).c $(CFLAGS)

$(SETRLIMIT): $(SETRLIMIT).o
	$(GCC) -o $(SETRLIMIT) obj/$(SETRLIMIT).o $(LDFLAGS)
$(SETRLIMIT).o:
	$(GCC) -o obj/$(SETRLIMIT).o -c $(SETRLIMIT).c $(CFLAGS)

$(SLEEP): $(SLEEP).o
	$(GCC) -o $(SLEEP) obj/$(SLEEP).o $(LDFLAGS)
$(SLEEP).o:
	$(GCC) -o obj/$(SLEEP).o -c $(SLEEP).c $(CFLAGS)

$(SYSCONF): $(SYSCONF).o
	$(GCC) -o $(SYSCONF) obj/$(SYSCONF).o $(LDFLAGS)
$(SYSCONF).o:
	$(GCC) -o obj/$(SYSCONF).o -c $(SYSCONF).c $(CFLAGS)

$(UALARM1): $(UALARM1).o
	$(GCC) -o $(UALARM1) obj/$(UALARM1).o $(LDFLAGS)
$(UALARM1).o:
	$(GCC) -o obj/$(UALARM1).o -c $(UALARM1).c $(CFLAGS)

$(UALARM2): $(UALARM2).o
	$(GCC) -o $(UALARM2) obj/$(UALARM2).o $(LDFLAGS)
$(UALARM2).o:
	$(GCC) -o obj/$(UALARM2).o -c $(UALARM2).c $(CFLAGS)

$(UNSETENV): $(UNSETENV).o
	$(GCC) -o $(UNSETENV) obj/$(UNSETENV).o $(LDFLAGS)
$(UNSETENV).o:
	$(GCC) -o obj/$(UNSETENV).o -c $(UNSETENV).c $(CFLAGS)

$(USLEEP): $(USLEEP).o
	$(GCC) -o $(USLEEP) obj/$(USLEEP).o $(LDFLAGS)
$(USLEEP).o:
	$(GCC) -o obj/$(USLEEP).o -c $(USLEEP).c $(CFLAGS)



#top Makefile.fbsd


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_DAEMON=1 -DHAVE_GETRUSAGE=1 -DHAVE_GETOPT_LONG_ONLY=1 -DHAVE_UNSETENV_RESULT=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ABORT       = abort
ALARM       = alarm
ATEXIT1     = atexit1
ATEXIT2     = atexit2
CLEARENV    = clearenv
CONFSTR     = confstr
DAEMON      = daemon
ENVIRON     = environ
EXIT        = exit
EXIT_FAILURE= EXIT_FAILURE
EXIT_SUCCESS= EXIT_SUCCESS
GETENV      = getenv
GETOPT      = getopt
GETOPT_LONG = getopt_long
GETOPT_LONG_ONLY= getopt_long_only
GETRLIMIT   = getrlimit
GETRUSAGE   = getrusage
NANOSLEEP   = nanosleep
ON_EXIT1    = on_exit1
ON_EXIT2    = on_exit2
PATHCONF    = pathconf
PAUSE1      = pause1
PAUSE2      = pause2
PERROR      = perror
PUTENV      = putenv
SETENV      = setenv
SETRLIMIT   = setrlimit
SLEEP       = sleep
SYSCONF     = sysconf
UALARM1     = ualarm1
UALARM2     = ualarm2
UNSETENV    = unsetenv
USLEEP      = usleep



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ABORT)
#make: $(ALARM)
#make: $(ATEXIT1)
#make: $(ATEXIT2)
#make: $(CLEARENV)
#make: $(CONFSTR)
#make: $(DAEMON)
#make: $(ENVIRON)
#make: $(EXIT)
#make: $(EXIT_FAILURE)
#make: $(EXIT_SUCCESS)
#make: $(GETENV)
#make: $(GETOPT)
#make: $(GETOPT_LONG)
#make: $(GETOPT_LONG_ONLY)
#make: $(GETRLIMIT)
#make: $(GETRUSAGE)
#make: $(NANOSLEEP)
#make: $(ON_EXIT1)
#make: $(ON_EXIT2)
#make: $(PATHCONF)
#make: $(PAUSE1)
#make: $(PAUSE2)
#make: $(PERROR)
#make: $(PUTENV)
#make: $(SETENV)
#make: $(SETRLIMIT)
#make: $(SLEEP)
#make: $(SYSCONF)
#make: $(UALARM1)
#make: $(UALARM2)
#make: $(UNSETENV)
#make: $(USLEEP)
make: $(ABORT) $(ALARM) $(ATEXIT1) $(ATEXIT2) $(CLEARENV) $(CONFSTR) $(DAEMON) $(ENVIRON) $(EXIT) $(EXIT_FAILURE) $(EXIT_SUCCESS) $(GETENV) $(GETOPT) $(GETOPT_LONG) $(GETOPT_LONG_ONLY) $(GETRLIMIT) $(GETRUSAGE) $(NANOSLEEP) $(ON_EXIT1) $(ON_EXIT2) $(PATHCONF) $(PAUSE1) $(PAUSE2) $(PERROR) $(PUTENV) $(SETENV) $(SETRLIMIT) $(SLEEP) $(SYSCONF) $(UALARM1) $(UALARM2) $(UNSETENV) $(USLEEP)



$(ABORT): $(ABORT).o
	$(GCC) -o $(ABORT) obj/$(ABORT).o $(LDFLAGS)
$(ABORT).o:
	$(GCC) -o obj/$(ABORT).o -c $(ABORT).c $(CFLAGS)

$(ALARM): $(ALARM).o
	$(GCC) -o $(ALARM) obj/$(ALARM).o $(LDFLAGS)
$(ALARM).o:
	$(GCC) -o obj/$(ALARM).o -c $(ALARM).c $(CFLAGS)

$(ATEXIT1): $(ATEXIT1).o
	$(GCC) -o $(ATEXIT1) obj/$(ATEXIT1).o $(LDFLAGS)
$(ATEXIT1).o:
	$(GCC) -o obj/$(ATEXIT1).o -c $(ATEXIT1).c $(CFLAGS)

$(ATEXIT2): $(ATEXIT2).o
	$(GCC) -o $(ATEXIT2) obj/$(ATEXIT2).o $(LDFLAGS)
$(ATEXIT2).o:
	$(GCC) -o obj/$(ATEXIT2).o -c $(ATEXIT2).c $(CFLAGS)

$(CLEARENV): $(CLEARENV).o
	$(GCC) -o $(CLEARENV) obj/$(CLEARENV).o $(LDFLAGS)
$(CLEARENV).o:
	$(GCC) -o obj/$(CLEARENV).o -c $(CLEARENV).c $(CFLAGS)

$(CONFSTR): $(CONFSTR).o
	$(GCC) -o $(CONFSTR) obj/$(CONFSTR).o $(LDFLAGS)
$(CONFSTR).o:
	$(GCC) -o obj/$(CONFSTR).o -c $(CONFSTR).c $(CFLAGS)

$(DAEMON): $(DAEMON).o
	$(GCC) -o $(DAEMON) obj/$(DAEMON).o $(LDFLAGS)
$(DAEMON).o:
	$(GCC) -o obj/$(DAEMON).o -c $(DAEMON).c $(CFLAGS)

$(ENVIRON): $(ENVIRON).o
	$(GCC) -o $(ENVIRON) obj/$(ENVIRON).o $(LDFLAGS)
$(ENVIRON).o:
	$(GCC) -o obj/$(ENVIRON).o -c $(ENVIRON).c $(CFLAGS)

$(EXIT): $(EXIT).o
	$(GCC) -o $(EXIT) obj/$(EXIT).o $(LDFLAGS)
$(EXIT).o:
	$(GCC) -o obj/$(EXIT).o -c $(EXIT).c $(CFLAGS)

$(EXIT_FAILURE): $(EXIT_FAILURE).o
	$(GCC) -o $(EXIT_FAILURE) obj/$(EXIT_FAILURE).o $(LDFLAGS)
$(EXIT_FAILURE).o:
	$(GCC) -o obj/$(EXIT_FAILURE).o -c $(EXIT_FAILURE).c $(CFLAGS)

$(EXIT_SUCCESS): $(EXIT_SUCCESS).o
	$(GCC) -o $(EXIT_SUCCESS) obj/$(EXIT_SUCCESS).o $(LDFLAGS)
$(EXIT_SUCCESS).o:
	$(GCC) -o obj/$(EXIT_SUCCESS).o -c $(EXIT_SUCCESS).c $(CFLAGS)

$(GETENV): $(GETENV).o
	$(GCC) -o $(GETENV) obj/$(GETENV).o $(LDFLAGS)
$(GETENV).o:
	$(GCC) -o obj/$(GETENV).o -c $(GETENV).c $(CFLAGS)

$(GETOPT): $(GETOPT).o
	$(GCC) -o $(GETOPT) obj/$(GETOPT).o $(LDFLAGS)
$(GETOPT).o:
	$(GCC) -o obj/$(GETOPT).o -c $(GETOPT).c $(CFLAGS)

$(GETOPT_LONG): $(GETOPT_LONG).o
	$(GCC) -o $(GETOPT_LONG) obj/$(GETOPT_LONG).o $(LDFLAGS)
$(GETOPT_LONG).o:
	$(GCC) -o obj/$(GETOPT_LONG).o -c $(GETOPT_LONG).c $(CFLAGS)

$(GETOPT_LONG_ONLY): $(GETOPT_LONG_ONLY).o
	$(GCC) -o $(GETOPT_LONG_ONLY) obj/$(GETOPT_LONG_ONLY).o $(LDFLAGS)
$(GETOPT_LONG_ONLY).o:
	$(GCC) -o obj/$(GETOPT_LONG_ONLY).o -c $(GETOPT_LONG_ONLY).c $(CFLAGS)

$(GETRLIMIT): $(GETRLIMIT).o
	$(GCC) -o $(GETRLIMIT) obj/$(GETRLIMIT).o $(LDFLAGS)
$(GETRLIMIT).o:
	$(GCC) -o obj/$(GETRLIMIT).o -c $(GETRLIMIT).c $(CFLAGS)

$(GETRUSAGE): $(GETRUSAGE).o
	$(GCC) -o $(GETRUSAGE) obj/$(GETRUSAGE).o $(LDFLAGS)
$(GETRUSAGE).o:
	$(GCC) -o obj/$(GETRUSAGE).o -c $(GETRUSAGE).c $(CFLAGS)

$(NANOSLEEP): $(NANOSLEEP).o
	$(GCC) -o $(NANOSLEEP) obj/$(NANOSLEEP).o $(LDFLAGS)
$(NANOSLEEP).o:
	$(GCC) -o obj/$(NANOSLEEP).o -c $(NANOSLEEP).c $(CFLAGS)

$(ON_EXIT1): $(ON_EXIT1).o
	$(GCC) -o $(ON_EXIT1) obj/$(ON_EXIT1).o $(LDFLAGS)
$(ON_EXIT1).o:
	$(GCC) -o obj/$(ON_EXIT1).o -c $(ON_EXIT1).c $(CFLAGS)

$(ON_EXIT2): $(ON_EXIT2).o
	$(GCC) -o $(ON_EXIT2) obj/$(ON_EXIT2).o $(LDFLAGS)
$(ON_EXIT2).o:
	$(GCC) -o obj/$(ON_EXIT2).o -c $(ON_EXIT2).c $(CFLAGS)

$(PATHCONF): $(PATHCONF).o
	$(GCC) -o $(PATHCONF) obj/$(PATHCONF).o $(LDFLAGS)
$(PATHCONF).o:
	$(GCC) -o obj/$(PATHCONF).o -c $(PATHCONF).c $(CFLAGS)

$(PAUSE1): $(PAUSE1).o
	$(GCC) -o $(PAUSE1) obj/$(PAUSE1).o $(LDFLAGS)
$(PAUSE1).o:
	$(GCC) -o obj/$(PAUSE1).o -c $(PAUSE1).c $(CFLAGS)

$(PAUSE2): $(PAUSE2).o
	$(GCC) -o $(PAUSE2) obj/$(PAUSE2).o $(LDFLAGS)
$(PAUSE2).o:
	$(GCC) -o obj/$(PAUSE2).o -c $(PAUSE2).c $(CFLAGS)

$(PERROR): $(PERROR).o
	$(GCC) -o $(PERROR) obj/$(PERROR).o $(LDFLAGS)
$(PERROR).o:
	$(GCC) -o obj/$(PERROR).o -c $(PERROR).c $(CFLAGS)

$(PUTENV): $(PUTENV).o
	$(GCC) -o $(PUTENV) obj/$(PUTENV).o $(LDFLAGS)
$(PUTENV).o:
	$(GCC) -o obj/$(PUTENV).o -c $(PUTENV).c $(CFLAGS)

$(SETENV): $(SETENV).o
	$(GCC) -o $(SETENV) obj/$(SETENV).o $(LDFLAGS)
$(SETENV).o:
	$(GCC) -o obj/$(SETENV).o -c $(SETENV).c $(CFLAGS)

$(SETRLIMIT): $(SETRLIMIT).o
	$(GCC) -o $(SETRLIMIT) obj/$(SETRLIMIT).o $(LDFLAGS)
$(SETRLIMIT).o:
	$(GCC) -o obj/$(SETRLIMIT).o -c $(SETRLIMIT).c $(CFLAGS)

$(SLEEP): $(SLEEP).o
	$(GCC) -o $(SLEEP) obj/$(SLEEP).o $(LDFLAGS)
$(SLEEP).o:
	$(GCC) -o obj/$(SLEEP).o -c $(SLEEP).c $(CFLAGS)

$(SYSCONF): $(SYSCONF).o
	$(GCC) -o $(SYSCONF) obj/$(SYSCONF).o $(LDFLAGS)
$(SYSCONF).o:
	$(GCC) -o obj/$(SYSCONF).o -c $(SYSCONF).c $(CFLAGS)

$(UALARM1): $(UALARM1).o
	$(GCC) -o $(UALARM1) obj/$(UALARM1).o $(LDFLAGS)
$(UALARM1).o:
	$(GCC) -o obj/$(UALARM1).o -c $(UALARM1).c $(CFLAGS)

$(UALARM2): $(UALARM2).o
	$(GCC) -o $(UALARM2) obj/$(UALARM2).o $(LDFLAGS)
$(UALARM2).o:
	$(GCC) -o obj/$(UALARM2).o -c $(UALARM2).c $(CFLAGS)

$(UNSETENV): $(UNSETENV).o
	$(GCC) -o $(UNSETENV) obj/$(UNSETENV).o $(LDFLAGS)
$(UNSETENV).o:
	$(GCC) -o obj/$(UNSETENV).o -c $(UNSETENV).c $(CFLAGS)

$(USLEEP): $(USLEEP).o
	$(GCC) -o $(USLEEP) obj/$(USLEEP).o $(LDFLAGS)
$(USLEEP).o:
	$(GCC) -o obj/$(USLEEP).o -c $(USLEEP).c $(CFLAGS)



#top Makefile.sol


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_DAEMON=1 -DHAVE_GETOPT_LONG_ONLY=1 -DHAVE_GETRUSAGE=1 -DHAVE_UNSETENV_RESULT=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ABORT       = abort
ALARM       = alarm
ATEXIT1     = atexit1
ATEXIT2     = atexit2
CLEARENV    = clearenv
CONFSTR     = confstr
DAEMON      = daemon
ENVIRON     = environ
EXIT        = exit
EXIT_FAILURE= EXIT_FAILURE
EXIT_SUCCESS= EXIT_SUCCESS
GETENV      = getenv
GETOPT      = getopt
GETOPT_LONG = getopt_long
GETOPT_LONG_ONLY= getopt_long_only
GETRLIMIT   = getrlimit
GETRUSAGE   = getrusage
NANOSLEEP   = nanosleep
ON_EXIT1    = on_exit1
ON_EXIT2    = on_exit2
PATHCONF    = pathconf
PAUSE1      = pause1
PAUSE2      = pause2
PERROR      = perror
PUTENV      = putenv
SETENV      = setenv
SETRLIMIT   = setrlimit
SLEEP       = sleep
SYSCONF     = sysconf
UALARM1     = ualarm1
UALARM2     = ualarm2
UNSETENV    = unsetenv
USLEEP      = usleep



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ABORT)
#make: $(ALARM)
#make: $(ATEXIT1)
#make: $(ATEXIT2)
#make: $(CLEARENV)
#make: $(CONFSTR)
#make: $(DAEMON)
#make: $(ENVIRON)
#make: $(EXIT)
#make: $(EXIT_FAILURE)
#make: $(EXIT_SUCCESS)
#make: $(GETENV)
#make: $(GETOPT)
#make: $(GETOPT_LONG)
#make: $(GETOPT_LONG_ONLY)
#make: $(GETRLIMIT)
#make: $(GETRUSAGE)
#make: $(NANOSLEEP)
#make: $(ON_EXIT1)
#make: $(ON_EXIT2)
#make: $(PATHCONF)
#make: $(PAUSE1)
#make: $(PAUSE2)
#make: $(PERROR)
#make: $(PUTENV)
#make: $(SETENV)
#make: $(SETRLIMIT)
#make: $(SLEEP)
#make: $(SYSCONF)
#make: $(UALARM1)
#make: $(UALARM2)
#make: $(UNSETENV)
#make: $(USLEEP)
make: $(ABORT) $(ALARM) $(ATEXIT1) $(ATEXIT2) $(CLEARENV) $(CONFSTR) $(DAEMON) $(ENVIRON) $(EXIT) $(EXIT_FAILURE) $(EXIT_SUCCESS) $(GETENV) $(GETOPT) $(GETOPT_LONG) $(GETOPT_LONG_ONLY) $(GETRLIMIT) $(GETRUSAGE) $(NANOSLEEP) $(ON_EXIT1) $(ON_EXIT2) $(PATHCONF) $(PAUSE1) $(PAUSE2) $(PERROR) $(PUTENV) $(SETENV) $(SETRLIMIT) $(SLEEP) $(SYSCONF) $(UALARM1) $(UALARM2) $(UNSETENV) $(USLEEP)



$(ABORT): $(ABORT).o
	$(GCC) -o $(ABORT) obj/$(ABORT).o $(LDFLAGS)
$(ABORT).o:
	$(GCC) -o obj/$(ABORT).o -c $(ABORT).c $(CFLAGS)

$(ALARM): $(ALARM).o
	$(GCC) -o $(ALARM) obj/$(ALARM).o $(LDFLAGS)
$(ALARM).o:
	$(GCC) -o obj/$(ALARM).o -c $(ALARM).c $(CFLAGS)

$(ATEXIT1): $(ATEXIT1).o
	$(GCC) -o $(ATEXIT1) obj/$(ATEXIT1).o $(LDFLAGS)
$(ATEXIT1).o:
	$(GCC) -o obj/$(ATEXIT1).o -c $(ATEXIT1).c $(CFLAGS)

$(ATEXIT2): $(ATEXIT2).o
	$(GCC) -o $(ATEXIT2) obj/$(ATEXIT2).o $(LDFLAGS)
$(ATEXIT2).o:
	$(GCC) -o obj/$(ATEXIT2).o -c $(ATEXIT2).c $(CFLAGS)

$(CLEARENV): $(CLEARENV).o
	$(GCC) -o $(CLEARENV) obj/$(CLEARENV).o $(LDFLAGS)
$(CLEARENV).o:
	$(GCC) -o obj/$(CLEARENV).o -c $(CLEARENV).c $(CFLAGS)

$(CONFSTR): $(CONFSTR).o
	$(GCC) -o $(CONFSTR) obj/$(CONFSTR).o $(LDFLAGS)
$(CONFSTR).o:
	$(GCC) -o obj/$(CONFSTR).o -c $(CONFSTR).c $(CFLAGS)

$(DAEMON): $(DAEMON).o
	$(GCC) -o $(DAEMON) obj/$(DAEMON).o $(LDFLAGS)
$(DAEMON).o:
	$(GCC) -o obj/$(DAEMON).o -c $(DAEMON).c $(CFLAGS)

$(ENVIRON): $(ENVIRON).o
	$(GCC) -o $(ENVIRON) obj/$(ENVIRON).o $(LDFLAGS)
$(ENVIRON).o:
	$(GCC) -o obj/$(ENVIRON).o -c $(ENVIRON).c $(CFLAGS)

$(EXIT): $(EXIT).o
	$(GCC) -o $(EXIT) obj/$(EXIT).o $(LDFLAGS)
$(EXIT).o:
	$(GCC) -o obj/$(EXIT).o -c $(EXIT).c $(CFLAGS)

$(EXIT_FAILURE): $(EXIT_FAILURE).o
	$(GCC) -o $(EXIT_FAILURE) obj/$(EXIT_FAILURE).o $(LDFLAGS)
$(EXIT_FAILURE).o:
	$(GCC) -o obj/$(EXIT_FAILURE).o -c $(EXIT_FAILURE).c $(CFLAGS)

$(EXIT_SUCCESS): $(EXIT_SUCCESS).o
	$(GCC) -o $(EXIT_SUCCESS) obj/$(EXIT_SUCCESS).o $(LDFLAGS)
$(EXIT_SUCCESS).o:
	$(GCC) -o obj/$(EXIT_SUCCESS).o -c $(EXIT_SUCCESS).c $(CFLAGS)

$(GETENV): $(GETENV).o
	$(GCC) -o $(GETENV) obj/$(GETENV).o $(LDFLAGS)
$(GETENV).o:
	$(GCC) -o obj/$(GETENV).o -c $(GETENV).c $(CFLAGS)

$(GETOPT): $(GETOPT).o
	$(GCC) -o $(GETOPT) obj/$(GETOPT).o $(LDFLAGS)
$(GETOPT).o:
	$(GCC) -o obj/$(GETOPT).o -c $(GETOPT).c $(CFLAGS)

$(GETOPT_LONG): $(GETOPT_LONG).o
	$(GCC) -o $(GETOPT_LONG) obj/$(GETOPT_LONG).o $(LDFLAGS)
$(GETOPT_LONG).o:
	$(GCC) -o obj/$(GETOPT_LONG).o -c $(GETOPT_LONG).c $(CFLAGS)

$(GETOPT_LONG_ONLY): $(GETOPT_LONG_ONLY).o
	$(GCC) -o $(GETOPT_LONG_ONLY) obj/$(GETOPT_LONG_ONLY).o $(LDFLAGS)
$(GETOPT_LONG_ONLY).o:
	$(GCC) -o obj/$(GETOPT_LONG_ONLY).o -c $(GETOPT_LONG_ONLY).c $(CFLAGS)

$(GETRLIMIT): $(GETRLIMIT).o
	$(GCC) -o $(GETRLIMIT) obj/$(GETRLIMIT).o $(LDFLAGS)
$(GETRLIMIT).o:
	$(GCC) -o obj/$(GETRLIMIT).o -c $(GETRLIMIT).c $(CFLAGS)

$(GETRUSAGE): $(GETRUSAGE).o
	$(GCC) -o $(GETRUSAGE) obj/$(GETRUSAGE).o $(LDFLAGS)
$(GETRUSAGE).o:
	$(GCC) -o obj/$(GETRUSAGE).o -c $(GETRUSAGE).c $(CFLAGS)

$(NANOSLEEP): $(NANOSLEEP).o
	$(GCC) -o $(NANOSLEEP) obj/$(NANOSLEEP).o $(LDFLAGS)
$(NANOSLEEP).o:
	$(GCC) -o obj/$(NANOSLEEP).o -c $(NANOSLEEP).c $(CFLAGS)

$(ON_EXIT1): $(ON_EXIT1).o
	$(GCC) -o $(ON_EXIT1) obj/$(ON_EXIT1).o $(LDFLAGS)
$(ON_EXIT1).o:
	$(GCC) -o obj/$(ON_EXIT1).o -c $(ON_EXIT1).c $(CFLAGS)

$(ON_EXIT2): $(ON_EXIT2).o
	$(GCC) -o $(ON_EXIT2) obj/$(ON_EXIT2).o $(LDFLAGS)
$(ON_EXIT2).o:
	$(GCC) -o obj/$(ON_EXIT2).o -c $(ON_EXIT2).c $(CFLAGS)

$(PATHCONF): $(PATHCONF).o
	$(GCC) -o $(PATHCONF) obj/$(PATHCONF).o $(LDFLAGS)
$(PATHCONF).o:
	$(GCC) -o obj/$(PATHCONF).o -c $(PATHCONF).c $(CFLAGS)

$(PAUSE1): $(PAUSE1).o
	$(GCC) -o $(PAUSE1) obj/$(PAUSE1).o $(LDFLAGS)
$(PAUSE1).o:
	$(GCC) -o obj/$(PAUSE1).o -c $(PAUSE1).c $(CFLAGS)

$(PAUSE2): $(PAUSE2).o
	$(GCC) -o $(PAUSE2) obj/$(PAUSE2).o $(LDFLAGS)
$(PAUSE2).o:
	$(GCC) -o obj/$(PAUSE2).o -c $(PAUSE2).c $(CFLAGS)

$(PERROR): $(PERROR).o
	$(GCC) -o $(PERROR) obj/$(PERROR).o $(LDFLAGS)
$(PERROR).o:
	$(GCC) -o obj/$(PERROR).o -c $(PERROR).c $(CFLAGS)

$(PUTENV): $(PUTENV).o
	$(GCC) -o $(PUTENV) obj/$(PUTENV).o $(LDFLAGS)
$(PUTENV).o:
	$(GCC) -o obj/$(PUTENV).o -c $(PUTENV).c $(CFLAGS)

$(SETENV): $(SETENV).o
	$(GCC) -o $(SETENV) obj/$(SETENV).o $(LDFLAGS)
$(SETENV).o:
	$(GCC) -o obj/$(SETENV).o -c $(SETENV).c $(CFLAGS)

$(SETRLIMIT): $(SETRLIMIT).o
	$(GCC) -o $(SETRLIMIT) obj/$(SETRLIMIT).o $(LDFLAGS)
$(SETRLIMIT).o:
	$(GCC) -o obj/$(SETRLIMIT).o -c $(SETRLIMIT).c $(CFLAGS)

$(SLEEP): $(SLEEP).o
	$(GCC) -o $(SLEEP) obj/$(SLEEP).o $(LDFLAGS)
$(SLEEP).o:
	$(GCC) -o obj/$(SLEEP).o -c $(SLEEP).c $(CFLAGS)

$(SYSCONF): $(SYSCONF).o
	$(GCC) -o $(SYSCONF) obj/$(SYSCONF).o $(LDFLAGS)
$(SYSCONF).o:
	$(GCC) -o obj/$(SYSCONF).o -c $(SYSCONF).c $(CFLAGS)

$(UALARM1): $(UALARM1).o
	$(GCC) -o $(UALARM1) obj/$(UALARM1).o $(LDFLAGS)
$(UALARM1).o:
	$(GCC) -o obj/$(UALARM1).o -c $(UALARM1).c $(CFLAGS)

$(UALARM2): $(UALARM2).o
	$(GCC) -o $(UALARM2) obj/$(UALARM2).o $(LDFLAGS)
$(UALARM2).o:
	$(GCC) -o obj/$(UALARM2).o -c $(UALARM2).c $(CFLAGS)

$(UNSETENV): $(UNSETENV).o
	$(GCC) -o $(UNSETENV) obj/$(UNSETENV).o $(LDFLAGS)
$(UNSETENV).o:
	$(GCC) -o obj/$(UNSETENV).o -c $(UNSETENV).c $(CFLAGS)

$(USLEEP): $(USLEEP).o
	$(GCC) -o $(USLEEP) obj/$(USLEEP).o $(LDFLAGS)
$(USLEEP).o:
	$(GCC) -o obj/$(USLEEP).o -c $(USLEEP).c $(CFLAGS)



#top Makefile.beos


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_CLEARENV=1 -DHAVE_GETOPT_LONG_ONLY=1 -DHAVE_UNSETENV_RESULT=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ABORT       = abort
ALARM       = alarm
ATEXIT1     = atexit1
ATEXIT2     = atexit2
CLEARENV    = clearenv
CONFSTR     = confstr
DAEMON      = daemon
ENVIRON     = environ
EXIT        = exit
EXIT_FAILURE= EXIT_FAILURE
EXIT_SUCCESS= EXIT_SUCCESS
GETENV      = getenv
GETOPT      = getopt
GETOPT_LONG = getopt_long
GETOPT_LONG_ONLY= getopt_long_only
GETRLIMIT   = getrlimit
GETRUSAGE   = getrusage
NANOSLEEP   = nanosleep
ON_EXIT1    = on_exit1
ON_EXIT2    = on_exit2
PATHCONF    = pathconf
PAUSE1      = pause1
PAUSE2      = pause2
PERROR      = perror
PUTENV      = putenv
SETENV      = setenv
SETRLIMIT   = setrlimit
SLEEP       = sleep
SYSCONF     = sysconf
UALARM1     = ualarm1
UALARM2     = ualarm2
UNSETENV    = unsetenv
USLEEP      = usleep



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ABORT)
#make: $(ALARM)
#make: $(ATEXIT1)
#make: $(ATEXIT2)
#make: $(CLEARENV)
#make: $(CONFSTR)
#make: $(DAEMON)
#make: $(ENVIRON)
#make: $(EXIT)
#make: $(EXIT_FAILURE)
#make: $(EXIT_SUCCESS)
#make: $(GETENV)
#make: $(GETOPT)
#make: $(GETOPT_LONG)
#make: $(GETOPT_LONG_ONLY)
#make: $(GETRLIMIT)
#make: $(GETRUSAGE)
#make: $(NANOSLEEP)
#make: $(ON_EXIT1)
#make: $(ON_EXIT2)
#make: $(PATHCONF)
#make: $(PAUSE1)
#make: $(PAUSE2)
#make: $(PERROR)
#make: $(PUTENV)
#make: $(SETENV)
#make: $(SETRLIMIT)
#make: $(SLEEP)
#make: $(SYSCONF)
#make: $(UALARM1)
#make: $(UALARM2)
#make: $(UNSETENV)
#make: $(USLEEP)
make: $(ABORT) $(ALARM) $(ATEXIT1) $(ATEXIT2) $(CLEARENV) $(CONFSTR) $(DAEMON) $(ENVIRON) $(EXIT) $(EXIT_FAILURE) $(EXIT_SUCCESS) $(GETENV) $(GETOPT) $(GETOPT_LONG) $(GETOPT_LONG_ONLY) $(GETRLIMIT) $(GETRUSAGE) $(NANOSLEEP) $(ON_EXIT1) $(ON_EXIT2) $(PATHCONF) $(PAUSE1) $(PAUSE2) $(PERROR) $(PUTENV) $(SETENV) $(SETRLIMIT) $(SLEEP) $(SYSCONF) $(UALARM1) $(UALARM2) $(UNSETENV) $(USLEEP)



$(ABORT): $(ABORT).o
	$(GCC) -o $(ABORT) obj/$(ABORT).o $(LDFLAGS)
$(ABORT).o:
	$(GCC) -o obj/$(ABORT).o -c $(ABORT).c $(CFLAGS)

$(ALARM): $(ALARM).o
	$(GCC) -o $(ALARM) obj/$(ALARM).o $(LDFLAGS)
$(ALARM).o:
	$(GCC) -o obj/$(ALARM).o -c $(ALARM).c $(CFLAGS)

$(ATEXIT1): $(ATEXIT1).o
	$(GCC) -o $(ATEXIT1) obj/$(ATEXIT1).o $(LDFLAGS)
$(ATEXIT1).o:
	$(GCC) -o obj/$(ATEXIT1).o -c $(ATEXIT1).c $(CFLAGS)

$(ATEXIT2): $(ATEXIT2).o
	$(GCC) -o $(ATEXIT2) obj/$(ATEXIT2).o $(LDFLAGS)
$(ATEXIT2).o:
	$(GCC) -o obj/$(ATEXIT2).o -c $(ATEXIT2).c $(CFLAGS)

$(CLEARENV): $(CLEARENV).o
	$(GCC) -o $(CLEARENV) obj/$(CLEARENV).o $(LDFLAGS)
$(CLEARENV).o:
	$(GCC) -o obj/$(CLEARENV).o -c $(CLEARENV).c $(CFLAGS)

$(CONFSTR): $(CONFSTR).o
	$(GCC) -o $(CONFSTR) obj/$(CONFSTR).o $(LDFLAGS)
$(CONFSTR).o:
	$(GCC) -o obj/$(CONFSTR).o -c $(CONFSTR).c $(CFLAGS)

$(DAEMON): $(DAEMON).o
	$(GCC) -o $(DAEMON) obj/$(DAEMON).o $(LDFLAGS)
$(DAEMON).o:
	$(GCC) -o obj/$(DAEMON).o -c $(DAEMON).c $(CFLAGS)

$(ENVIRON): $(ENVIRON).o
	$(GCC) -o $(ENVIRON) obj/$(ENVIRON).o $(LDFLAGS)
$(ENVIRON).o:
	$(GCC) -o obj/$(ENVIRON).o -c $(ENVIRON).c $(CFLAGS)

$(EXIT): $(EXIT).o
	$(GCC) -o $(EXIT) obj/$(EXIT).o $(LDFLAGS)
$(EXIT).o:
	$(GCC) -o obj/$(EXIT).o -c $(EXIT).c $(CFLAGS)

$(EXIT_FAILURE): $(EXIT_FAILURE).o
	$(GCC) -o $(EXIT_FAILURE) obj/$(EXIT_FAILURE).o $(LDFLAGS)
$(EXIT_FAILURE).o:
	$(GCC) -o obj/$(EXIT_FAILURE).o -c $(EXIT_FAILURE).c $(CFLAGS)

$(EXIT_SUCCESS): $(EXIT_SUCCESS).o
	$(GCC) -o $(EXIT_SUCCESS) obj/$(EXIT_SUCCESS).o $(LDFLAGS)
$(EXIT_SUCCESS).o:
	$(GCC) -o obj/$(EXIT_SUCCESS).o -c $(EXIT_SUCCESS).c $(CFLAGS)

$(GETENV): $(GETENV).o
	$(GCC) -o $(GETENV) obj/$(GETENV).o $(LDFLAGS)
$(GETENV).o:
	$(GCC) -o obj/$(GETENV).o -c $(GETENV).c $(CFLAGS)

$(GETOPT): $(GETOPT).o
	$(GCC) -o $(GETOPT) obj/$(GETOPT).o $(LDFLAGS)
$(GETOPT).o:
	$(GCC) -o obj/$(GETOPT).o -c $(GETOPT).c $(CFLAGS)

$(GETOPT_LONG): $(GETOPT_LONG).o
	$(GCC) -o $(GETOPT_LONG) obj/$(GETOPT_LONG).o $(LDFLAGS)
$(GETOPT_LONG).o:
	$(GCC) -o obj/$(GETOPT_LONG).o -c $(GETOPT_LONG).c $(CFLAGS)

$(GETOPT_LONG_ONLY): $(GETOPT_LONG_ONLY).o
	$(GCC) -o $(GETOPT_LONG_ONLY) obj/$(GETOPT_LONG_ONLY).o $(LDFLAGS)
$(GETOPT_LONG_ONLY).o:
	$(GCC) -o obj/$(GETOPT_LONG_ONLY).o -c $(GETOPT_LONG_ONLY).c $(CFLAGS)

$(GETRLIMIT): $(GETRLIMIT).o
	$(GCC) -o $(GETRLIMIT) obj/$(GETRLIMIT).o $(LDFLAGS)
$(GETRLIMIT).o:
	$(GCC) -o obj/$(GETRLIMIT).o -c $(GETRLIMIT).c $(CFLAGS)

$(GETRUSAGE): $(GETRUSAGE).o
	$(GCC) -o $(GETRUSAGE) obj/$(GETRUSAGE).o $(LDFLAGS)
$(GETRUSAGE).o:
	$(GCC) -o obj/$(GETRUSAGE).o -c $(GETRUSAGE).c $(CFLAGS)

$(NANOSLEEP): $(NANOSLEEP).o
	$(GCC) -o $(NANOSLEEP) obj/$(NANOSLEEP).o $(LDFLAGS)
$(NANOSLEEP).o:
	$(GCC) -o obj/$(NANOSLEEP).o -c $(NANOSLEEP).c $(CFLAGS)

$(ON_EXIT1): $(ON_EXIT1).o
	$(GCC) -o $(ON_EXIT1) obj/$(ON_EXIT1).o $(LDFLAGS)
$(ON_EXIT1).o:
	$(GCC) -o obj/$(ON_EXIT1).o -c $(ON_EXIT1).c $(CFLAGS)

$(ON_EXIT2): $(ON_EXIT2).o
	$(GCC) -o $(ON_EXIT2) obj/$(ON_EXIT2).o $(LDFLAGS)
$(ON_EXIT2).o:
	$(GCC) -o obj/$(ON_EXIT2).o -c $(ON_EXIT2).c $(CFLAGS)

$(PATHCONF): $(PATHCONF).o
	$(GCC) -o $(PATHCONF) obj/$(PATHCONF).o $(LDFLAGS)
$(PATHCONF).o:
	$(GCC) -o obj/$(PATHCONF).o -c $(PATHCONF).c $(CFLAGS)

$(PAUSE1): $(PAUSE1).o
	$(GCC) -o $(PAUSE1) obj/$(PAUSE1).o $(LDFLAGS)
$(PAUSE1).o:
	$(GCC) -o obj/$(PAUSE1).o -c $(PAUSE1).c $(CFLAGS)

$(PAUSE2): $(PAUSE2).o
	$(GCC) -o $(PAUSE2) obj/$(PAUSE2).o $(LDFLAGS)
$(PAUSE2).o:
	$(GCC) -o obj/$(PAUSE2).o -c $(PAUSE2).c $(CFLAGS)

$(PERROR): $(PERROR).o
	$(GCC) -o $(PERROR) obj/$(PERROR).o $(LDFLAGS)
$(PERROR).o:
	$(GCC) -o obj/$(PERROR).o -c $(PERROR).c $(CFLAGS)

$(PUTENV): $(PUTENV).o
	$(GCC) -o $(PUTENV) obj/$(PUTENV).o $(LDFLAGS)
$(PUTENV).o:
	$(GCC) -o obj/$(PUTENV).o -c $(PUTENV).c $(CFLAGS)

$(SETENV): $(SETENV).o
	$(GCC) -o $(SETENV) obj/$(SETENV).o $(LDFLAGS)
$(SETENV).o:
	$(GCC) -o obj/$(SETENV).o -c $(SETENV).c $(CFLAGS)

$(SETRLIMIT): $(SETRLIMIT).o
	$(GCC) -o $(SETRLIMIT) obj/$(SETRLIMIT).o $(LDFLAGS)
$(SETRLIMIT).o:
	$(GCC) -o obj/$(SETRLIMIT).o -c $(SETRLIMIT).c $(CFLAGS)

$(SLEEP): $(SLEEP).o
	$(GCC) -o $(SLEEP) obj/$(SLEEP).o $(LDFLAGS)
$(SLEEP).o:
	$(GCC) -o obj/$(SLEEP).o -c $(SLEEP).c $(CFLAGS)

$(SYSCONF): $(SYSCONF).o
	$(GCC) -o $(SYSCONF) obj/$(SYSCONF).o $(LDFLAGS)
$(SYSCONF).o:
	$(GCC) -o obj/$(SYSCONF).o -c $(SYSCONF).c $(CFLAGS)

$(UALARM1): $(UALARM1).o
	$(GCC) -o $(UALARM1) obj/$(UALARM1).o $(LDFLAGS)
$(UALARM1).o:
	$(GCC) -o obj/$(UALARM1).o -c $(UALARM1).c $(CFLAGS)

$(UALARM2): $(UALARM2).o
	$(GCC) -o $(UALARM2) obj/$(UALARM2).o $(LDFLAGS)
$(UALARM2).o:
	$(GCC) -o obj/$(UALARM2).o -c $(UALARM2).c $(CFLAGS)

$(UNSETENV): $(UNSETENV).o
	$(GCC) -o $(UNSETENV) obj/$(UNSETENV).o $(LDFLAGS)
$(UNSETENV).o:
	$(GCC) -o obj/$(UNSETENV).o -c $(UNSETENV).c $(CFLAGS)

$(USLEEP): $(USLEEP).o
	$(GCC) -o $(USLEEP) obj/$(USLEEP).o $(LDFLAGS)
$(USLEEP).o:
	$(GCC) -o obj/$(USLEEP).o -c $(USLEEP).c $(CFLAGS)



#top Makefile.win


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        =
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing
LIBS        = -lm
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = del /q /s
MKDCMD      = mkdir

ABORT       = abort
ALARM       = alarm
ATEXIT1     = atexit1
ATEXIT2     = atexit2
CLEARENV    = clearenv
CONFSTR     = confstr
DAEMON      = daemon
ENVIRON     = environ
EXIT        = exit
EXIT_FAILURE= EXIT_FAILURE
EXIT_SUCCESS= EXIT_SUCCESS
GETENV      = getenv
GETOPT      = getopt
GETOPT_LONG = getopt_long
GETOPT_LONG_ONLY= getopt_long_only
GETRLIMIT   = getrlimit
GETRUSAGE   = getrusage
NANOSLEEP   = nanosleep
ON_EXIT1    = on_exit1
ON_EXIT2    = on_exit2
PATHCONF    = pathconf
PAUSE1      = pause1
PAUSE2      = pause2
PERROR      = perror
PUTENV      = putenv
SETENV      = setenv
SETRLIMIT   = setrlimit
SLEEP       = sleep
SYSCONF     = sysconf
UALARM1     = ualarm1
UALARM2     = ualarm2
UNSETENV    = unsetenv
USLEEP      = usleep



all: make

objdir:
	$(MKDCMD) obj\

clean:
	$(RM) obj\*.o *.o *~

#make: $(ABORT)
#make: $(ALARM)
#make: $(ATEXIT1)
#make: $(ATEXIT2)
#make: $(CLEARENV)
#make: $(CONFSTR)
#make: $(DAEMON)
#make: $(ENVIRON)
#make: $(EXIT)
#make: $(EXIT_FAILURE)
#make: $(EXIT_SUCCESS)
#make: $(GETENV)
#make: $(GETOPT)
#make: $(GETOPT_LONG)
#make: $(GETOPT_LONG_ONLY)
#make: $(GETRLIMIT)
#make: $(GETRUSAGE)
#make: $(NANOSLEEP)
#make: $(ON_EXIT1)
#make: $(ON_EXIT2)
#make: $(PATHCONF)
#make: $(PAUSE1)
#make: $(PAUSE2)
#make: $(PERROR)
#make: $(PUTENV)
#make: $(SETENV)
#make: $(SETRLIMIT)
#make: $(SLEEP)
#make: $(SYSCONF)
#make: $(UALARM1)
#make: $(UALARM2)
#make: $(UNSETENV)
#make: $(USLEEP)
make: $(ABORT) $(ALARM) $(ATEXIT1) $(ATEXIT2) $(CLEARENV) $(CONFSTR) $(DAEMON) $(ENVIRON) $(EXIT) $(EXIT_FAILURE) $(EXIT_SUCCESS) $(GETENV) $(GETOPT) $(GETOPT_LONG) $(GETOPT_LONG_ONLY) $(GETRLIMIT) $(GETRUSAGE) $(NANOSLEEP) $(ON_EXIT1) $(ON_EXIT2) $(PATHCONF) $(PAUSE1) $(PAUSE2) $(PERROR) $(PUTENV) $(SETENV) $(SETRLIMIT) $(SLEEP) $(SYSCONF) $(UALARM1) $(UALARM2) $(UNSETENV) $(USLEEP)



$(ABORT): $(ABORT).o
	$(GCC) -o $(ABORT) obj/$(ABORT).o $(LDFLAGS)
$(ABORT).o:
	$(GCC) -o obj/$(ABORT).o -c $(ABORT).c $(CFLAGS)

$(ALARM): $(ALARM).o
	$(GCC) -o $(ALARM) obj/$(ALARM).o $(LDFLAGS)
$(ALARM).o:
	$(GCC) -o obj/$(ALARM).o -c $(ALARM).c $(CFLAGS)

$(ATEXIT1): $(ATEXIT1).o
	$(GCC) -o $(ATEXIT1) obj/$(ATEXIT1).o $(LDFLAGS)
$(ATEXIT1).o:
	$(GCC) -o obj/$(ATEXIT1).o -c $(ATEXIT1).c $(CFLAGS)

$(ATEXIT2): $(ATEXIT2).o
	$(GCC) -o $(ATEXIT2) obj/$(ATEXIT2).o $(LDFLAGS)
$(ATEXIT2).o:
	$(GCC) -o obj/$(ATEXIT2).o -c $(ATEXIT2).c $(CFLAGS)

$(CLEARENV): $(CLEARENV).o
	$(GCC) -o $(CLEARENV) obj/$(CLEARENV).o $(LDFLAGS)
$(CLEARENV).o:
	$(GCC) -o obj/$(CLEARENV).o -c $(CLEARENV).c $(CFLAGS)

$(CONFSTR): $(CONFSTR).o
	$(GCC) -o $(CONFSTR) obj/$(CONFSTR).o $(LDFLAGS)
$(CONFSTR).o:
	$(GCC) -o obj/$(CONFSTR).o -c $(CONFSTR).c $(CFLAGS)

$(DAEMON): $(DAEMON).o
	$(GCC) -o $(DAEMON) obj/$(DAEMON).o $(LDFLAGS)
$(DAEMON).o:
	$(GCC) -o obj/$(DAEMON).o -c $(DAEMON).c $(CFLAGS)

$(ENVIRON): $(ENVIRON).o
	$(GCC) -o $(ENVIRON) obj/$(ENVIRON).o $(LDFLAGS)
$(ENVIRON).o:
	$(GCC) -o obj/$(ENVIRON).o -c $(ENVIRON).c $(CFLAGS)

$(EXIT): $(EXIT).o
	$(GCC) -o $(EXIT) obj/$(EXIT).o $(LDFLAGS)
$(EXIT).o:
	$(GCC) -o obj/$(EXIT).o -c $(EXIT).c $(CFLAGS)

$(EXIT_FAILURE): $(EXIT_FAILURE).o
	$(GCC) -o $(EXIT_FAILURE) obj/$(EXIT_FAILURE).o $(LDFLAGS)
$(EXIT_FAILURE).o:
	$(GCC) -o obj/$(EXIT_FAILURE).o -c $(EXIT_FAILURE).c $(CFLAGS)

$(EXIT_SUCCESS): $(EXIT_SUCCESS).o
	$(GCC) -o $(EXIT_SUCCESS) obj/$(EXIT_SUCCESS).o $(LDFLAGS)
$(EXIT_SUCCESS).o:
	$(GCC) -o obj/$(EXIT_SUCCESS).o -c $(EXIT_SUCCESS).c $(CFLAGS)

$(GETENV): $(GETENV).o
	$(GCC) -o $(GETENV) obj/$(GETENV).o $(LDFLAGS)
$(GETENV).o:
	$(GCC) -o obj/$(GETENV).o -c $(GETENV).c $(CFLAGS)

$(GETOPT): $(GETOPT).o
	$(GCC) -o $(GETOPT) obj/$(GETOPT).o $(LDFLAGS)
$(GETOPT).o:
	$(GCC) -o obj/$(GETOPT).o -c $(GETOPT).c $(CFLAGS)

$(GETOPT_LONG): $(GETOPT_LONG).o
	$(GCC) -o $(GETOPT_LONG) obj/$(GETOPT_LONG).o $(LDFLAGS)
$(GETOPT_LONG).o:
	$(GCC) -o obj/$(GETOPT_LONG).o -c $(GETOPT_LONG).c $(CFLAGS)

$(GETOPT_LONG_ONLY): $(GETOPT_LONG_ONLY).o
	$(GCC) -o $(GETOPT_LONG_ONLY) obj/$(GETOPT_LONG_ONLY).o $(LDFLAGS)
$(GETOPT_LONG_ONLY).o:
	$(GCC) -o obj/$(GETOPT_LONG_ONLY).o -c $(GETOPT_LONG_ONLY).c $(CFLAGS)

$(GETRLIMIT): $(GETRLIMIT).o
	$(GCC) -o $(GETRLIMIT) obj/$(GETRLIMIT).o $(LDFLAGS)
$(GETRLIMIT).o:
	$(GCC) -o obj/$(GETRLIMIT).o -c $(GETRLIMIT).c $(CFLAGS)

$(GETRUSAGE): $(GETRUSAGE).o
	$(GCC) -o $(GETRUSAGE) obj/$(GETRUSAGE).o $(LDFLAGS)
$(GETRUSAGE).o:
	$(GCC) -o obj/$(GETRUSAGE).o -c $(GETRUSAGE).c $(CFLAGS)

$(NANOSLEEP): $(NANOSLEEP).o
	$(GCC) -o $(NANOSLEEP) obj/$(NANOSLEEP).o $(LDFLAGS)
$(NANOSLEEP).o:
	$(GCC) -o obj/$(NANOSLEEP).o -c $(NANOSLEEP).c $(CFLAGS)

$(ON_EXIT1): $(ON_EXIT1).o
	$(GCC) -o $(ON_EXIT1) obj/$(ON_EXIT1).o $(LDFLAGS)
$(ON_EXIT1).o:
	$(GCC) -o obj/$(ON_EXIT1).o -c $(ON_EXIT1).c $(CFLAGS)

$(ON_EXIT2): $(ON_EXIT2).o
	$(GCC) -o $(ON_EXIT2) obj/$(ON_EXIT2).o $(LDFLAGS)
$(ON_EXIT2).o:
	$(GCC) -o obj/$(ON_EXIT2).o -c $(ON_EXIT2).c $(CFLAGS)

$(PATHCONF): $(PATHCONF).o
	$(GCC) -o $(PATHCONF) obj/$(PATHCONF).o $(LDFLAGS)
$(PATHCONF).o:
	$(GCC) -o obj/$(PATHCONF).o -c $(PATHCONF).c $(CFLAGS)

$(PAUSE1): $(PAUSE1).o
	$(GCC) -o $(PAUSE1) obj/$(PAUSE1).o $(LDFLAGS)
$(PAUSE1).o:
	$(GCC) -o obj/$(PAUSE1).o -c $(PAUSE1).c $(CFLAGS)

$(PAUSE2): $(PAUSE2).o
	$(GCC) -o $(PAUSE2) obj/$(PAUSE2).o $(LDFLAGS)
$(PAUSE2).o:
	$(GCC) -o obj/$(PAUSE2).o -c $(PAUSE2).c $(CFLAGS)

$(PERROR): $(PERROR).o
	$(GCC) -o $(PERROR) obj/$(PERROR).o $(LDFLAGS)
$(PERROR).o:
	$(GCC) -o obj/$(PERROR).o -c $(PERROR).c $(CFLAGS)

$(PUTENV): $(PUTENV).o
	$(GCC) -o $(PUTENV) obj/$(PUTENV).o $(LDFLAGS)
$(PUTENV).o:
	$(GCC) -o obj/$(PUTENV).o -c $(PUTENV).c $(CFLAGS)

$(SETENV): $(SETENV).o
	$(GCC) -o $(SETENV) obj/$(SETENV).o $(LDFLAGS)
$(SETENV).o:
	$(GCC) -o obj/$(SETENV).o -c $(SETENV).c $(CFLAGS)

$(SETRLIMIT): $(SETRLIMIT).o
	$(GCC) -o $(SETRLIMIT) obj/$(SETRLIMIT).o $(LDFLAGS)
$(SETRLIMIT).o:
	$(GCC) -o obj/$(SETRLIMIT).o -c $(SETRLIMIT).c $(CFLAGS)

$(SLEEP): $(SLEEP).o
	$(GCC) -o $(SLEEP) obj/$(SLEEP).o $(LDFLAGS)
$(SLEEP).o:
	$(GCC) -o obj/$(SLEEP).o -c $(SLEEP).c $(CFLAGS)

$(SYSCONF): $(SYSCONF).o
	$(GCC) -o $(SYSCONF) obj/$(SYSCONF).o $(LDFLAGS)
$(SYSCONF).o:
	$(GCC) -o obj/$(SYSCONF).o -c $(SYSCONF).c $(CFLAGS)

$(UALARM1): $(UALARM1).o
	$(GCC) -o $(UALARM1) obj/$(UALARM1).o $(LDFLAGS)
$(UALARM1).o:
	$(GCC) -o obj/$(UALARM1).o -c $(UALARM1).c $(CFLAGS)

$(UALARM2): $(UALARM2).o
	$(GCC) -o $(UALARM2) obj/$(UALARM2).o $(LDFLAGS)
$(UALARM2).o:
	$(GCC) -o obj/$(UALARM2).o -c $(UALARM2).c $(CFLAGS)

$(UNSETENV): $(UNSETENV).o
	$(GCC) -o $(UNSETENV) obj/$(UNSETENV).o $(LDFLAGS)
$(UNSETENV).o:
	$(GCC) -o obj/$(UNSETENV).o -c $(UNSETENV).c $(CFLAGS)

$(USLEEP): $(USLEEP).o
	$(GCC) -o $(USLEEP) obj/$(USLEEP).o $(LDFLAGS)
$(USLEEP).o:
	$(GCC) -o obj/$(USLEEP).o -c $(USLEEP).c $(CFLAGS)





#top Predefined Constants


#top EINTR


Deklaracja stałej EINTR znajduje się w pliku nagłówkowym asm-generic/errno-base.h.
Deklaracja stałej EINTR jest następująca:
#define EINTR            4      /* Interrupted system call */



#top EFBIG


Deklaracja stałej EFBIG znajduje się w pliku nagłówkowym asm-generic/errno-base.h.
Deklaracja stałej EFBIG jest następująca:
#define EFBIG       27  /* File too large */



#top ENOMEM


Deklaracja stałej ENOMEM znajduje się w pliku nagłówkowym asm-generic/errno-base.h.
Deklaracja stałej ENOMEM jest następująca:
#define ENOMEM      12  /* Out of memory */



#top EMFILE


Deklaracja stałej EMFILE znajduje się w pliku nagłówkowym asm-generic/errno-base.h.
Deklaracja stałej EMFILE jest następująca:
#define EMFILE      24  /* Too many open files */



#top EXIT_FAILURE


Deklaracja stałej EXIT_FAILURE znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja stałej EXIT_FAILURE jest następująca:
/* We define these the same for all machines.
   Changes from this to the outside world should be done in `_exit'.  */
#define EXIT_FAILURE    1   /* Failing exit status.  */

Powiązane:
EXIT_FAILURE, EXIT_SUCCESS, abort(), atexit(), exit(), on_exit(),

Opis:
Stała EXIT_FAILURE

Example:
zawartość pliku EXIT_FAILURE.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */



int main(int argc, char **argv) {
	char *self;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage:   %s\n", argv[0]);
		return 0;
	}
	
	printf("%s: exit(EXIT_FAILURE=%d): call...\n", self, EXIT_FAILURE);
	exit(EXIT_FAILURE);
	printf("%s: exit(EXIT_FAILURE=%d): end.\n", self, EXIT_FAILURE);
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/EXIT_FAILURE; echo $?
program wyświetli stosowne informacje o sposobie działania:
EXIT_FAILURE: exit(EXIT_FAILURE=1): call...
1
Aby dostrzec rezultat należy uważniej przyjrzeć się kodu źródłowemu programu, po wywołaniu funkcji exit(EXIT_FAILURE); znajduje się jeszcze wywołanie funkcji printf();, który nie zostaje wykonany, gdyż działanie programu kończy się w momencie wywołania wcześniejszej funkcji exit(EXIT_FAILURE);, powyższy kod źródłowy dobrze to obrazuje. Dodatkowo należy zwrócić uwagę na wartość (kod zakończenia) którą zwraca program w wyniku zakończenia: 1, powyższy sposób dobrze obrazuje w jaki sposób zakończyć program sygnalizując niepowodzenie wykonania przez program zadania.



#top EXIT_SUCCESS


Deklaracja stałej EXIT_SUCCESS znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja stałej EXIT_SUCCESS jest następująca:
/* We define these the same for all machines.
   Changes from this to the outside world should be done in `_exit'.  */
#define EXIT_SUCCESS    0   /* Successful exit status.  */

Powiązane:
EXIT_FAILURE, EXIT_SUCCESS, abort(), atexit(), exit(), on_exit(),

Opis:
Stała EXIT_SUCCESS

Example:
zawartość pliku EXIT_SUCCESS.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */



int main(int argc, char **argv) {
	char *self;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage:   %s\n", argv[0]);
		return 0;
	}
	
	printf("%s: exit(EXIT_SUCCESS=%d): call...\n", self, EXIT_SUCCESS);
	exit(EXIT_SUCCESS);
	printf("%s: exit(EXIT_SUCCESS=%d): end.\n", self, EXIT_SUCCESS);
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/EXIT_SUCCESS; echo $?
program wyświetli stosowne informacje o sposobie działania:
EXIT_SUCCESS: exit(EXIT_SUCCESS=0): call...
0
Aby dostrzec rezultat należy uważniej przyjrzeć się kodu źródłowemu programu, po wywołaniu funkcji exit(EXIT_SUCCESS); znajduje się jeszcze wywołanie funkcji printf();, który nie zostaje wykonany, gdyż działanie programu kończy się w momencie wywołania wcześniejszej funkcji exit(EXIT_SUCCESS);, powyższy kod źródłowy dobrze to obrazuje. Dodatkowo należy zwrócić uwagę na wartość (kod zakończenia) którą zwraca program w wyniku zakończenia: 0, powyższy sposób dobrze obrazuje w jaki sposób zakończyć program sygnalizując sukcesem zakończone wykonane przez program zadanie.



#top PRIO_MAX


Deklaracja stałej PRIO_MAX znajduje się w pliku nagłówkowym bits/resource.h.
Deklaracja stałej PRIO_MAX jest następująca:
/* Priority limits.  */
#define PRIO_MAX        20      /* Maximum priority a process can have.  */



#top PRIO_MIN


Deklaracja stałej PRIO_MIN znajduje się w pliku nagłówkowym bits/resource.h.
Deklaracja stałej PRIO_MIN jest następująca:
/* Priority limits.  */
#define PRIO_MIN        -20     /* Minimum priority a process can have.  */



#top SIG_DFL


Deklaracja stałej SIG_DFL znajduje się w pliku nagłówkowym bits/signum.h.
Deklaracja stałej SIG_DFL jest następująca:
/* Fake signal functions.  */
#define SIG_DFL ((__sighandler_t) 0)        :* Default action.  */



#top SIG_IGN


Deklaracja stałej SIG_IGN znajduje się w pliku nagłówkowym bits/signum.h.
Deklaracja stałej SIG_IGN jest następująca:
/* Fake signal functions.  */
#define SIG_IGN ((__sighandler_t) 1)        :* Ignore signal.  */



#top SIGABRT


Deklaracja stałej SIGABRT znajduje się w pliku nagłówkowym bits/signum.h.
Deklaracja stałej SIGABRT jest następująca:
/* Signals.  */
#define SIGABRT     6   /* Abort (ANSI).  */



#top SIGALRM


Deklaracja stałej SIGALRM znajduje się w pliku nagłówkowym bits/signum.h.
Deklaracja stałej SIGALRM jest następująca:
/* Signals.  */
#define SIGALRM     14  /* Alarm clock (POSIX).  */



#top SIGSEGV


Deklaracja stałej SIGSEGV znajduje się w pliku nagłówkowym bits/signum.h.
Deklaracja stałej SIGSEGV jest następująca:
/* Signals.  */
#define SIGSEGV     11  /* Segmentation violation (ANSI).  */



#top SIGXCPU


Deklaracja stałej SIGXCPU znajduje się w pliku nagłówkowym bits/signum.h.
Deklaracja stałej SIGXCPU jest następująca:
/* Signals.  */
#define SIGXCPU     24  /* CPU limit exceeded (4.2 BSD).  */





#top Datatypes / MACROS


#top __restorefn_t


Definicja typu __restorefn_t znajduje się w pliku nagłówkowym asm-generic/signal.h.
Definicja typu __restorefn_t jest następująca:
typedef void __restorefn_t(void);



#top __rlim_t


Definicja typu __rlim_t znajduje się w pliku nagłówkowym bits/types.h.
Definicja typu __rlim_t jest następująca:
__STD_TYPE __RLIM_T_TYPE __rlim_t;  /* Type for resource measurement.  */



#top __rlimit_resource_t


Definicja typu __rlimit_resource_t znajduje się w pliku nagłówkowym sys/resource.h.
Definicja typu __rlimit_resource_t jest następująca:
#if defined __USE_GNU && !defined __cplusplus
typedef enum __rlimit_resource __rlimit_resource_t;
[...]
#else
typedef int __rlimit_resource_t;
[...]
#endif



#top __rusage_who_t


Definicja typu __rusage_who_t znajduje się w pliku nagłówkowym sys/resource.h.
Definicja typu __rusage_who_t jest następująca:
#if defined __USE_GNU && !defined __cplusplus
[...]
typedef enum __rusage_who __rusage_who_t;
[...]
#else
[...]
typedef int __rusage_who_t;
[...]
#endif



#top __sigrestore_t


Definicja typu __sigrestore_t znajduje się w pliku nagłówkowym asm-generic/signal.h.
Definicja typu __sigrestore_t jest następująca:
typedef __restorefn_t *__sigrestore_t;



#top __sighandler_t


Definicja typu __sighandler_t znajduje się w pliku nagłówkowym asm-generic/signal.h.
Definicja typu __sighandler_t jest następująca:
typedef __signalfn_t *__sighandler_t;



#top __signalfn_t


Definicja typu __signalfn_t znajduje się w pliku nagłówkowym asm-generic/signal.h.
Definicja typu __signalfn_t jest następująca:
typedef void __signalfn_t(int);



#top __suseconds_t


Definicja typu __suseconds_t znajduje się w pliku nagłówkowym bits/types.h.
Definicja typu __suseconds_t jest następująca:
__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds.  */



#top __time_t


Definicja typu __time_t znajduje się w pliku nagłówkowym bits/types.h.
Definicja typu __time_t jest następująca:
__STD_TYPE __TIME_T_TYPE __time_t;        /* Seconds since the Epoch.  */



#top __useconds_t


Definicja typu __useconds_t znajduje się w pliku nagłówkowym bits/types.h.
Definicja typu __useconds_t jest następująca:
__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds.  */



#top enum __rlimit_resource


Definicja typu enum __rlimit_resource znajduje się w pliku nagłówkowym bits/resource.h.
Definicja typu enum __rlimit_resource jest następująca:
/* Kinds of resource limit.  */
enum __rlimit_resource
{
  /* Per-process CPU limit, in seconds.  */
  RLIMIT_CPU = 0,
#define RLIMIT_CPU RLIMIT_CPU

  /* Largest file that can be created, in bytes.  */
  RLIMIT_FSIZE = 1,
#define RLIMIT_FSIZE RLIMIT_FSIZE

  /* Maximum size of data segment, in bytes.  */
  RLIMIT_DATA = 2,
#define RLIMIT_DATA RLIMIT_DATA

  /* Maximum size of stack segment, in bytes.  */
  RLIMIT_STACK = 3,
#define RLIMIT_STACK RLIMIT_STACK

  /* Largest core file that can be created, in bytes.  */
  RLIMIT_CORE = 4,
#define RLIMIT_CORE RLIMIT_CORE

  /* Largest resident set size, in bytes.
     This affects swapping; processes that are exceeding their
     resident set size will be more likely to have physical memory
     taken from them.  */
  __RLIMIT_RSS = 5,
#define RLIMIT_RSS __RLIMIT_RSS

  /* Number of open files.  */
  RLIMIT_NOFILE = 7,
  __RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same.  */
#define RLIMIT_NOFILE RLIMIT_NOFILE
#define RLIMIT_OFILE __RLIMIT_OFILE

  /* Address space limit.  */
  RLIMIT_AS = 9,
#define RLIMIT_AS RLIMIT_AS

  /* Number of processes.  */
  __RLIMIT_NPROC = 6,
#define RLIMIT_NPROC __RLIMIT_NPROC

  /* Locked-in-memory address space.  */
  __RLIMIT_MEMLOCK = 8,
#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK

  /* Maximum number of file locks.  */
  __RLIMIT_LOCKS = 10,
#define RLIMIT_LOCKS __RLIMIT_LOCKS

  /* Maximum number of pending signals.  */
  __RLIMIT_SIGPENDING = 11,
#define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING

  /* Maximum bytes in POSIX message queues.  */
  __RLIMIT_MSGQUEUE = 12,
#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE

  /* Maximum nice priority allowed to raise to.
     Nice levels 19 .. -20 correspond to 0 .. 39
     values of this resource limit.  */
  __RLIMIT_NICE = 13,
#define RLIMIT_NICE __RLIMIT_NICE

  /* Maximum realtime priority allowed for non-priviledged
     processes.  */
  __RLIMIT_RTPRIO = 14,
#define RLIMIT_RTPRIO __RLIMIT_RTPRIO

  __RLIMIT_NLIMITS = 15,
  __RLIM_NLIMITS = __RLIMIT_NLIMITS
#define RLIMIT_NLIMITS __RLIMIT_NLIMITS
#define RLIM_NLIMITS __RLIM_NLIMITS
};



#top enum __rusage_who


Definicja typu enum __rusage_who znajduje się w pliku nagłówkowym bits/resource.h.
Definicja typu enum __rusage_who jest następująca:
/* Whose usage statistics do you want?  */
enum __rusage_who
{
  /* The calling process.  */
  RUSAGE_SELF = 0,
#define RUSAGE_SELF RUSAGE_SELF

  /* All of its terminated child processes.  */
  RUSAGE_CHILDREN = -1
#define RUSAGE_CHILDREN RUSAGE_CHILDREN
};



#top errno


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja globalnej zmiennej errno znajduje się w pliku nagłówkowym errno.h.
Deklaracja globalnej zmiennej errno jest następująca:
/* Declare the `errno' variable, unless it's defined as a macro by
   bits/errno.h.  This is the case in GNU, where it is a per-thread
   variable.  This redeclaration using the macro still works, but it
   will be a function declaration without a prototype and may trigger
   a -Wstrict-prototypes warning.  */
#ifndef errno
extern int errno;
#endif

Powiązane:
errno, perror(), strerror(),

Opis:
Globalna zmienna errno jest makrem przechowującym informację o kodzie błędu jaki wystąpił podczas ostatniego wywoływania najczęściej funkcji systemowej (en.wiki:syscall, pl.wiki:syscall). Kod błędu ustawiony w makrze errno pozwala poinformować program/użytkownika o przyczynie niepowodzenia ostanio wykonywanej operacji.



#top environ


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja zmiennej globalnej environ znajduje się w pliku nagłówkowym unistd.h.
Deklaracja zmiennej globalnej environ jest następująca:
/* NULL-terminated array of "NAME=VALUE" environment variables.  */
extern char **__environ;
#ifdef __USE_GNU
extern char **environ;
#endif

Powiązane:
environ, clearenv(), getenv(), putenv(), setenv(), unsetenv(),

Opis:
Zmienna globalna environ jest tablicą zakończoną (zawierającą ostatni element) wartością NULL przechowującą zmienne środowiskowe w postaci "NAME=VALUE".

Example:
zawartość pliku environ.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <unistd.h>        /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */
                           /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */
                           /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */



int main(int argc, char **argv) {
	char *self;
#if defined(HAVE_ENVIRON)
	char **envrow;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", argv[0]);
		return 0;
	}
	
#if defined(HAVE_ENVIRON)

	for (envrow=__environ;*envrow!=NULL;envrow++) {
		printf("%s: __environ:envrow=|%s|\n", self, *envrow);
	}
	
#ifdef __USE_GNU
	for (envrow=environ;*envrow!=NULL;envrow++) {
		printf("%s: environ:envrow=|%s|\n", self, *envrow);
	}
#endif
	
#endif
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/environ
program wyświetli stosowne informacje o sposobie działania:
environ: __environ:envrow=|SSH_AGENT_PID=5812|
environ: __environ:envrow=|KDE_MULTIHEAD=false|
environ: __environ:envrow=|HOSTNAME=*****|
environ: __environ:envrow=|DM_CONTROL=/var/run/xdmctl|
environ: __environ:envrow=|IFS=
|
environ: __environ:envrow=|TERM=xterm|
environ: __environ:envrow=|SHELL=/bin/bash|
environ: __environ:envrow=|HISTSIZE=10000|
environ: __environ:envrow=|XDM_MANAGED=/var/run/xdmctl/xdmctl-:0,maysd,mayfn,sched,rsvd,method=classic|
environ: __environ:envrow=|KDE_NO_IPV6=1|
environ: __environ:envrow=|GS_LIB=/home/user/.fonts|
environ: __environ:envrow=|WINDOWID=46137351|
environ: __environ:envrow=|QTDIR=/usr/lib/qt-3.3|
environ: __environ:envrow=|QTINC=/usr/lib/qt-3.3/include|
environ: __environ:envrow=|KDE_FULL_SESSION=true|
environ: __environ:envrow=|USER=user|
environ: __environ:envrow=|LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:|
environ: __environ:envrow=|SSH_AUTH_SOCK=/tmp/ssh-FCqpjA5790/agent.5790|
environ: __environ:envrow=|KDEDIR=/usr|
environ: __environ:envrow=|SESSION_MANAGER=local/*****:/tmp/.ICE-unix/5907|
environ: __environ:envrow=|PAGER=less|
environ: __environ:envrow=|XDG_CONFIG_DIRS=/etc/kde/xdg:/etc/xdg|
environ: __environ:envrow=|KONSOLE_DCOP=DCOPRef(konsole-6607,konsole)|
environ: __environ:envrow=|MAIL=/var/spool/mail/user|
environ: __environ:envrow=|DESKTOP_SESSION=default|
environ: __environ:envrow=|PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/usr/X11R6/sbin:/home/local/sbin:/home/local/bin|
environ: __environ:envrow=|INPUTRC=/etc/inputrc|
environ: __environ:envrow=|PWD=/home/user|
environ: __environ:envrow=|KONSOLE_DCOP_SESSION=DCOPRef(konsole-6607,session-11)|
environ: __environ:envrow=|KDE_IS_PRELINKED=1|
environ: __environ:envrow=|LANG=pl_PL.UTF-8|
environ: __environ:envrow=|PS1=[\u@\h \W]\$ |
environ: __environ:envrow=|HISTCONTROL=ignoredups|
environ: __environ:envrow=|SHLVL=6|
environ: __environ:envrow=|HOME=/home/user|
environ: __environ:envrow=|LANGUAGE=pl_PL.UTF-8|
environ: __environ:envrow=|GREP_OPTIONS=--color=auto|
environ: __environ:envrow=|LESS= -R -R|
environ: __environ:envrow=|LOGNAME=user|
environ: __environ:envrow=|QTLIB=/usr/lib/qt-3.3/lib|
environ: __environ:envrow=|LESSOPEN=|/usr/bin/lesspipe.sh %s|
environ: __environ:envrow=|DISPLAY=:0|
environ: __environ:envrow=|G_BROKEN_FILENAMES=1|
environ: __environ:envrow=|HISTFILE=/home/user/.kde/share/apps/konsole/sessions/myphp-docs---hist12|
environ: __environ:envrow=|COLORTERM=|
environ: __environ:envrow=|_=/home/local/code/ansiccode/misc/environ|
environ: environ:envrow=|SSH_AGENT_PID=5812|
environ: environ:envrow=|KDE_MULTIHEAD=false|
environ: environ:envrow=|HOSTNAME=*****|
environ: environ:envrow=|DM_CONTROL=/var/run/xdmctl|
environ: environ:envrow=|IFS=
|
environ: environ:envrow=|TERM=xterm|
environ: environ:envrow=|SHELL=/bin/bash|
environ: environ:envrow=|HISTSIZE=10000|
environ: environ:envrow=|XDM_MANAGED=/var/run/xdmctl/xdmctl-:0,maysd,mayfn,sched,rsvd,method=classic|
environ: environ:envrow=|KDE_NO_IPV6=1|
environ: environ:envrow=|GS_LIB=/home/user/.fonts|
environ: environ:envrow=|WINDOWID=46137351|
environ: environ:envrow=|QTDIR=/usr/lib/qt-3.3|
environ: environ:envrow=|QTINC=/usr/lib/qt-3.3/include|
environ: environ:envrow=|KDE_FULL_SESSION=true|
environ: environ:envrow=|USER=user|
environ: environ:envrow=|LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:|
environ: environ:envrow=|SSH_AUTH_SOCK=/tmp/ssh-FCqpjA5790/agent.5790|
environ: environ:envrow=|KDEDIR=/usr|
environ: environ:envrow=|SESSION_MANAGER=local/*****:/tmp/.ICE-unix/5907|
environ: environ:envrow=|PAGER=less|
environ: environ:envrow=|XDG_CONFIG_DIRS=/etc/kde/xdg:/etc/xdg|
environ: environ:envrow=|KONSOLE_DCOP=DCOPRef(konsole-6607,konsole)|
environ: environ:envrow=|MAIL=/var/spool/mail/user|
environ: environ:envrow=|DESKTOP_SESSION=default|
environ: environ:envrow=|PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/usr/X11R6/sbin:/home/local/sbin:/home/local/bin|
environ: environ:envrow=|INPUTRC=/etc/inputrc|
environ: environ:envrow=|PWD=/home/user|
environ: environ:envrow=|KONSOLE_DCOP_SESSION=DCOPRef(konsole-6607,session-11)|
environ: environ:envrow=|KDE_IS_PRELINKED=1|
environ: environ:envrow=|LANG=pl_PL.UTF-8|
environ: environ:envrow=|PS1=[\u@\h \W]\$ |
environ: environ:envrow=|HISTCONTROL=ignoredups|
environ: environ:envrow=|SHLVL=6|
environ: environ:envrow=|HOME=/home/user|
environ: environ:envrow=|LANGUAGE=pl_PL.UTF-8|
environ: environ:envrow=|GREP_OPTIONS=--color=auto|
environ: environ:envrow=|LESS= -R -R|
environ: environ:envrow=|LOGNAME=user|
environ: environ:envrow=|QTLIB=/usr/lib/qt-3.3/lib|
environ: environ:envrow=|LESSOPEN=|/usr/bin/lesspipe.sh %s|
environ: environ:envrow=|DISPLAY=:0|
environ: environ:envrow=|G_BROKEN_FILENAMES=1|
environ: environ:envrow=|HISTFILE=/home/user/.kde/share/apps/konsole/sessions/myphp-docs---hist12|
environ: environ:envrow=|COLORTERM=|
environ: environ:envrow=|_=/home/local/code/ansiccode/misc/environ|



#top rlim_t


Definicja typu rlim_t znajduje się w pliku nagłówkowym bits/resource.h.
Definicja typu rlim_t jest następująca:
/* Type for resource quantity measurement.  */
#ifndef __USE_FILE_OFFSET64
typedef __rlim_t rlim_t;
#else
typedef __rlim64_t rlim_t;
#endif



#top struct option


Definicja typu struct option znajduje się w pliku nagłówkowym getopt.h.
Definicja typu struct option jest następująca:
/* Describe the long-named options requested by the application.
   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
   of `struct option' terminated by an element containing a name which is
   zero.

   The field `has_arg' is:
   no_argument          (or 0) if the option does not take an argument,
   required_argument    (or 1) if the option requires an argument,
   optional_argument    (or 2) if the option takes an optional argument.

   If the field `flag' is not NULL, it points to a variable that is set
   to the value given in the field `val' when the option is found, but
   left unchanged if the option is not found.

   To have a long-named option do something other than set an `int' to
   a compiled-in constant, such as set a value from `optarg', set the
   option's `flag' field to zero and its `val' field to a nonzero
   value (the equivalent single-letter option character, if there is
   one).  For long options that have a zero `flag' field, `getopt'
   returns the contents of the `val' field.  */

struct option
{
  const char *name;
  /* has_arg can't be an enum because some compilers complain about
     type mismatches in all the code that assumes it is an int.  */
  int has_arg;
  int *flag;
  int val;
};



#top struct rusage


Definicja struktury struct rusage znajduje się w pliku nagłówkowym bits/resource.h.
Definicja struktury struct rusage jest następująca:
/* Structure which says how much of each resource has been used.  */
struct rusage
  {
    /* Total amount of user time used.  */
    struct timeval ru_utime;
    /* Total amount of system time used.  */
    struct timeval ru_stime;
    /* Maximum resident set size (in kilobytes).  */
    long int ru_maxrss;
    /* Amount of sharing of text segment memory
       with other processes (kilobyte-seconds).  */
    long int ru_ixrss;
    /* Amount of data segment memory used (kilobyte-seconds).  */
    long int ru_idrss;
    /* Amount of stack memory used (kilobyte-seconds).  */
    long int ru_isrss;
    /* Number of soft page faults (i.e. those serviced by reclaiming
       a page from the list of pages awaiting reallocation.  */
    long int ru_minflt;
    /* Number of hard page faults (i.e. those that required I/O).  */
    long int ru_majflt;
    /* Number of times a process was swapped out of physical memory.  */
    long int ru_nswap;
    /* Number of input operations via the file system.  Note: This
       and `ru_oublock' do not include operations with the cache.  */
    long int ru_inblock;
    /* Number of output operations via the file system.  */
    long int ru_oublock;
    /* Number of IPC messages sent.  */
    long int ru_msgsnd;
    /* Number of IPC messages received.  */
    long int ru_msgrcv;
    /* Number of signals delivered.  */
    long int ru_nsignals;
    /* Number of voluntary context switches, i.e. because the process
       gave up the process before it had to (usually to wait for some
       resource to be available).  */
    long int ru_nvcsw;
    /* Number of involuntary context switches, i.e. a higher priority process
       became runnable or the current process used up its time slice.  */
    long int ru_nivcsw;
  };



#top struct rlimit


Definicja struktury struct rlimit znajduje się w pliku nagłówkowym bits/resource.h.
Definicja struktury struct rlimit jest następująca:
struct rlimit
  {
    /* The current (soft) limit.  */
    rlim_t rlim_cur;
    /* The hard limit.  */
    rlim_t rlim_max;
  };



#top struct timespec


Definicja struktury struct timespec znajduje się w pliku nagłówkowym time.h.
Definicja struktury struct timespec jest następująca:
/* POSIX.1b structure for a time value.  This is like a `struct timeval' but
   has nanoseconds instead of microseconds.  */
struct timespec
  {
    __time_t tv_sec;        :* Seconds.  */
    long int tv_nsec;       /* Nanoseconds.  */
  };



#top struct timeval


Definicja struktury struct timeval znajduje się w pliku nagłówkowym bits/time.h.
Definicja struktury struct timeval jest następująca:
/* A time value that is accurate to the nearest
   microsecond but also has a range of years.  */
struct timeval
  {
    __time_t tv_sec;        :* Seconds.  */
    __suseconds_t tv_usec;  :* Microseconds.  */
  };





#top Miscellaneous Functions


#top abort


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji abort() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji abort() jest następująca:
/* Abort execution and generate a core-dump.  */
extern void abort (void) __THROW __attribute__ ((__noreturn__));

Powiązane:
EXIT_FAILURE, EXIT_SUCCESS, abort(), atexit(), exit(), on_exit(),

Opis:
Funkcja abort() przerywa działanie aplikacji. Funkcja abort() generuje sygnał SIGABRT co domyślnie wywołuje zakończenie programu, zwracając do środowiska kod błędu zależny od platformy. Program jest zamykany bez wywoływania destruktorów i funkcji atexit() lub at_quick_exit().

Argumenty:
Funkcja nie przyjmuje żadnych argumentów.

Zwracana wartość:
Funkcja nie zwraca żadnej wartości.

Example:
zawartość pliku abort.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */



int main(int argc, char **argv) {
	char *self;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<2) {
		printf("Usage: %s <arg>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s test\n", argv[0]);
		return 0;
	}
	
	/*
	Aborts the current process, producing an abnormal program termination.
	
	The function raises the SIGABRT signal (as if raise(SIGABRT) was called). This, if uncaught, causes the program to terminate returning a platform-dependent unsuccessful termination error code to the host environment.
	*/
	if (argc==2) abort();
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/abort
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/misc/abort <arg>
Examples:
       /home/local/code/ansiccode/misc/abort test

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/abort test
rezultat będzie zależny od podanych argumentów wywołania programu:
Aborted



#top alarm


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji alarm() znajduje się w pliku nagłówkowym unistd.h.
Deklaracja funkcji alarm() jest następująca:
/* Schedule an alarm.  In SECONDS seconds, the process will get a SIGALRM.
   If SECONDS is zero, any currently scheduled alarm will be cancelled.
   The function returns the number of seconds remaining until the last
   alarm scheduled would have signaled, or zero if there wasn't one.
   There is no return value to indicate an error, but you can set `errno'
   to 0 and check its value after calling `alarm', and this might tell you.
   The signal may come late due to processor scheduling.  */
extern unsigned int alarm (unsigned int __seconds) __THROW;

Powiązane:
alarm(), ualarm(),

Opis:
Funkcja alarm() ustawia czas po którym jądro systemu operacyjnego wygeneruje sygnał SIGALRM dla procesu wywołującego funkcję alarm(). Jeśli podany jako argument czas jest ustawiony na 0, funkcja anuluje ustawiony wczesniej alarm.

Argumenty:
unsigned int __seconds - czas po którym jądro systemu operacyjnego wygeneruje sygnał SIGALRM dla procesu wywołującego funkcję alarm().

Zwracana wartość:
unsigned int - wartość czasu pozostała do wysłania sygnału SIGALRM w przypadku wcześniej ustawionego czasu wygenerowania sygnału SIGALRM, który jeszcze nie upłynął. W przypadku gdy nie ma ustawionego żadnego jeszcze czasu wygenerowania sygnału SIGALRM lub poprzednio ustawiony czas wygenerowania sygnału SIGALRM już upłynął funkcja zwraca 0.

Example:
zawartość pliku alarm.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <unistd.h>        /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */
                           /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */
                           /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */
#include <signal.h>        /* for SIGHUP, SIGINT, SIGQUIT, SIG_DFL, SIG_ERR, */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <winbase.h>     /* for (struct)FILETIME, (struct)PROCESS_INFORMATION, (struct)SYSTEMTIME, (struct)WIN32_FIND_DATAA, (struct)SYSTEM_INFO, (struct)TIME_ZONE_INFORMATION, */
                           /* for OpenFile(), CreateFile(), CreateDirectory(), ReadFile(), WriteFile(), CloseHandle(), */
                           /* for CompareFileTime(), DosDateTimeToFileTime(), FileTimeToLocalFileTime(), GetFileTime(), LocalFileTimeToFileTime(), SetFileTime(), SystemTimeToFileTime(), */
#endif

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
/* Sleep - Capital first letter */
/* #include <windows.h> + #include <winbase.h> +++ -lws_32 */
#define sleep(time) Sleep(1000*time)
#define usleep(useconds) Sleep((useconds+999) / 1000)
#endif



void ALARMhandler(int sig) {
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	int result;
#endif
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* SIGALRM is not available on this OS platform !!! */
#else
	signal(SIGALRM, SIG_IGN);          /* ignore this signal */
#endif
	printf("ALARMhandler(int sig=%d): Hello\n", sig);
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* SIGALRM is not available on this OS platform !!! */
	/* alarm() is not available on this OS platform !!! */
#else
	signal(SIGALRM, ALARMhandler);     /* reinstall the handler */
	result=alarm(1);
	printf("ALARMhandler(int sig=%d): result=alarm(1): result=%d\n", sig, result);
#endif
}

int main(int argc, char **argv) {
	char *self;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	int result;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", argv[0]);
		return 0;
	}
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* SIGALRM is not available on this OS platform !!! */
	/* signal() is not available on this OS platform !!! */
	/* alarm() is not available on this OS platform !!! */
	printf("%s: SIGALRM is not available on this OS platform !!!\n", argv[0]);
	printf("%s: signal() is not available on this OS platform !!!\n", argv[0]);
	printf("%s: alarm() is not available on this OS platform !!!\n", argv[0]);
#else
	signal(SIGALRM, ALARMhandler);
	result=alarm(1);
	printf("%s: result=alarm(1): result=%d\n", self, result);
#endif
	
	while (1) sleep(1);
	printf("All done\n");
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/alarm
program wyświetli stosowne informacje o sposobie działania (ze względu na nieskończoną pętlę znajdującą się w programie działanie programu należy przerwać, zakońcyć kombinacją klawiszyCTRL+C):
alarm: result=alarm(1): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=alarm(1): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=alarm(1): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=alarm(1): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=alarm(1): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=alarm(1): result=0



#top atexit


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji atexit() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji atexit() jest następująca:
/* Register a function to be called when `exit' is called.  *:
extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));

Powiązane:
EXIT_FAILURE, EXIT_SUCCESS, abort(), atexit(), exit(), on_exit(),

Opis:
Funkcja atexit() rejestruje funkcje, które wywoływane w przypadku prawidłowego zakończenia programu. W przypadku normalnego zakończenia programu funkcje wywoływane są w odwrotnej kolejności w której zostały zarejestrowane. Ostatnio zarejestrowana funkcja w przypadku prawidłowego zakończenia programu zostanie wywołana jako pierwsza.

Argumenty:
void (*__func) (void) - wskaźnik do funkcji (funkcja nie przyjmująca żadnych argumentów oraz nie zwracająca żadnych wartości) która zostanie wywołana w przypadku normalnego zakończenia programu.

Zwracana wartość:
int - w przypadku poprawnej rejestracji funkcji zwracana jest wartość 0, w przeciwym przypadku zwracana jest nie zerowa wartość.

Example:
zawartość pliku atexit1.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */



void fnExit1(void) {
	printf("fnExit1(void): Exit function 1.\n");
}

void fnExit2(void) {
	printf("fnExit2(void): Exit function 2.\n");
}



int main(int argc, char **argv) {
	char *self;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", argv[0]);
		return 0;
	}
	
	atexit(fnExit1);
	atexit(fnExit2);
	printf("%s: main(): Main function.\n", self);
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/atexit1
program wyświetli stosowne informacje o sposobie działania:
atexit1: main(): Main function.
fnExit2(void): Exit function 2.
fnExit1(void): Exit function 1.

Example:
zawartość pliku atexit2.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */



void fnExit1(void) {
	printf("fnExit1(void): Exit function 1.\n");
}

void fnExit2(void) {
	printf("fnExit2(void): Exit function 2.\n");
}



int main(int argc, char **argv) {
	char *self;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", argv[0]);
		return 0;
	}
	
	atexit(fnExit2);
	atexit(fnExit1);
	printf("%s: main(): Main function.\n", self);
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/atexit2
program wyświetli stosowne informacje o sposobie działania:
atexit2: main(): Main function.
fnExit1(void): Exit function 1.
fnExit2(void): Exit function 2.

Powyższe dwa przykłady doskonale obrazują odwrotną kolejność wywoływania funkcji przy zakończeniu programu w której zostały zarejestrowane.



#top clearenv


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji clearenv() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji clearenv() jest następująca:
/* The `clearenv' was planned to be added to POSIX.1 but probably
   never made it.  Nevertheless the POSIX.9 standard (POSIX bindings
   for Fortran 77) requires this function.  */
extern int clearenv (void) __THROW;

Powiązane:
environ, clearenv(), getenv(), putenv(), setenv(), unsetenv(),

Opis:
Funkcja clearenv() czyści środowisko (usuwa wszystkie zmienne środowiskowe) oraz ustawia globalną zmienną environ na NULL.

Argumenty:
Funkcja nie przyjmuje żadnych argumentów.

Zwracana wartość:
int - w przypadku poprawnego wyczyszczenia środowiska (usunięcia zmiennych środowiskowych) zwracana jest wartość 0, w przeciwym przypadku zwracana jest nie zerowa wartość.

Example:
zawartość pliku clearenv.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <errno.h>         /* for errno constant, error constants, */



int main(int argc, char **argv) {
	char *self;
#if defined(HAVE_CLEARENV)
	int result;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", self);
		return 0;
	}
	
#if defined(HAVE_CLEARENV)
	result=clearenv();
	if (result==0) printf("%s: result=clearenv(): result=%d if (result>=0): Successful clearenv().\n", self, result);
	else           printf("%s: result=clearenv(): result=%d if (result>=0): else: Unable to clearenv(), Reason: %d:%s\n", self, result, errno, strerror(errno));
	printf("%s: execute /bin/bash: system(\"/bin/bash\");\n", self);
	system("/bin/bash");
#else
	/* clearenv() is not available on this OS platform !!! */
	printf("%s: clearenv() is not available on this OS platform !!!\n", self);
#endif
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/clearenv
program wyświetli stosowne informacje o sposobie działania (po wywołaniu clearenv() zostanie wywołana funkcja system("/bin/bash"); uruchamiające powłokę w celu umożliwienia sprawdzenia rezultatu działania clearenv() poprzez np: wyświetlenie poleceniem env lub export zmiennych środowiskowych, dla porównania można w drugiej konsoli również wyświetlić zmienne środowiskowe i porównać wyniki):
clearenv: result=clearenv(): result=0 if (result>=0): Successful clearenv().
clearenv: execute /bin/bash: system("/bin/bash");



#top daemon


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji daemon() znajduje się w pliku nagłówkowym unistd.h.
Deklaracja funkcji daemon() jest następująca:
/* Put the program in the background, and dissociate from the controlling
   terminal.  If NOCHDIR is zero, do `chdir (":")'.  If NOCLOSE is zero,
   redirects stdin, stdout, and stderr to :dev/null.  */
extern int daemon (int __nochdir, int __noclose) __THROW __wur;

Powiązane:

Opis:
Funkcja daemon() przeznaczona jest dla programów, które odłączają się od konsoli i działają w tle jako usługi (demony systemowe).

Argumenty:
int __nochdir - dla zerowej wartości argumentu __nochdir funkcja daemon() zmienia bieżący katalog roboczy na root ("/").
int __noclose - dla zerowej wartości argumentu __noclose funkcja daemon() przekierowywuje standardowe wejście, standardowe wyjście i standardowe wyście błędów na /dev/null.

Zwracana wartość:
int - Funkcja wywołuje funkcję fork() i w przypadku pomyślnego wywołania funkcji fork() proces rodzica (nadrzędny) wywołuje exit(0), w związku z czym przyszłe błędy są widoczne tylko dla procesu dziecka (podrzędnego). W przypadku sukcesu funkcja daemon() zwraca wartość 0. W przypadku wystąpienia błędu funkcja daemon() zwraca -1 i ustawia globalną zmienną errno na odpowiedni kod błędu wyspecyfikowany dla funkcji fork() and setsid().

Example:
zawartość pliku daemon.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <unistd.h>        /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */
                           /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */
                           /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */
#include <errno.h>         /* for errno constant, error constants, */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <winbase.h>     /* for (struct)FILETIME, (struct)PROCESS_INFORMATION, (struct)SYSTEMTIME, (struct)WIN32_FIND_DATAA, (struct)SYSTEM_INFO, (struct)TIME_ZONE_INFORMATION, */
                           /* for OpenFile(), CreateFile(), CreateDirectory(), ReadFile(), WriteFile(), CloseHandle(), */
                           /* for CompareFileTime(), DosDateTimeToFileTime(), FileTimeToLocalFileTime(), GetFileTime(), LocalFileTimeToFileTime(), SetFileTime(), SystemTimeToFileTime(), */
#endif

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
/* Sleep - Capital first letter */
/* #include <windows.h> + #include <winbase.h> +++ -lws_32 */
#define sleep(time) Sleep(1000*time)
#define usleep(useconds) Sleep((useconds+999) / 1000)
#endif



int main(int argc, char **argv) {
	char *self;
	int nochdir;
	int noclose;
#if defined(DHAVE_DAEMON)
	int result;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<3) {
		printf("Usage: %s <nochdir=0|1> <close=0|1>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s 0 0\n", argv[0]);
		return 0;
	}
	
	nochdir=atoi(argv[1]);
	noclose=atoi(argv[2]);
#if defined(DHAVE_DAEMON)
	result=daemon(nochdir, noclose);
	if (result>=0) printf("%s: result=daemon(nochdir=%d, noclose=%d): result=%d if (result>=0): Successful daemonize program.\n", self, nochdir, noclose, result);
	else           printf("%s: result=daemon(nochdir=%d, noclose=%d): result=%d if (result>=0): else: Unable to daemonize program, Reason: %d:%s\n", self, nochdir, noclose, result, errno, strerror(errno));
#else
	/* daemon() is not available on this OS platform !!! */
	printf("%s: daemon() is not available on this OS platform !!!\n", argv[0]);
#endif
	
	printf("%s: sleep(30);\n", self);
	sleep(30);
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/daemon
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/misc/daemon <nochdir=0|1> <close=0|1>
Examples:
       /home/local/code/ansiccode/misc/daemon 0 0

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/daemon 0 0
rezultat będzie zależny od podanych argumentów wywołania programu:
Aby dostrzec rezultat, należy wyświetlić listę procesów, jak widać w powyższym kodzie programu program wywołuje funkcję sleep(30) i przez 30 sekund od uruchomienia jest odłączony do konsoli z której został uruchomiony (program stał się daemonem).



#top exit


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji exit() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji exit() jest następująca:
/* Call all functions registered with `atexit' and `on_exit',
   in the reverse of the order in which they were registered
   perform stdio cleanup, and terminate program execution with STATUS.  */
extern void exit (int __status) __THROW __attribute__ ((__noreturn__));

Powiązane:
EXIT_FAILURE, EXIT_SUCCESS, abort(), atexit(), exit(), on_exit(),

Opis:
Funkcja exit() powoduje normalne zakończenue programu i wartość (__status & 0377) jest zwracana do procesu rodzica (tylko 8 najmniej znaczących bitów), który uruchomił program. Wszystkie funkcje zarejestrowane za pomocą atexit() i:lub on_exit() są wykonywane podczas zakończenia programu. Wszystkie zbuforowane dane w strumieniach są zapisanywane i zamykane. Pliki utworzone za pomocą funkcji tmpfile() są usuwane.

Argumenty:
int __status - wartość (kod powrotu) zwracana do procesu rodzica (tylko 8 najmniej znaczących bitów), w pliku nagłówkowym stdlib.h zdefiniowane są dwie stałe EXIT_SUCCESS oraz EXIT_FAILURE, które mogą być użyte jako argumenty wywołania funkcji exit() w celu zwrócenia statusu normalnego zakończenia działania programu lub zakończenia programu z błędem.

Zwracana wartość:
Funkcja nie zwraca żadnej wartości.

Example:
zawartość pliku exit.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */



int main(int argc, char **argv) {
	char *self;
	int exitcode;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<2) {
		printf("Usage: %s <exitcode>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s 0; echo $?\n", argv[0]);
		printf("       %s 1; echo $?\n", argv[0]);
		printf("       %s 2; echo $?\n", argv[0]);
		return 0;
	}
	
	exitcode=atoi(argv[1]);
	printf("%s: exitcode=atoi(argv[1]=%s): exitcode=%d\n", self, argv[1], exitcode);
	
	printf("%s: exit(exitcode=%d): call...\n", self, exitcode);
	exit(exitcode);
	printf("%s: exit(exitcode=%d): end.\n", self, exitcode);
	
	printf("%s: return 0;\n", self);
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/exit
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/misc/exit <exitcode>
Examples:
       /home/local/code/ansiccode/misc/exit 0; echo $?
       /home/local/code/ansiccode/misc/exit 1; echo $?
       /home/local/code/ansiccode/misc/exit 2; echo $?

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/exit 0; echo $?
/home/local/code/ansiccode/misc/exit 1; echo $?
/home/local/code/ansiccode/misc/exit 2; echo $?
rezultat będzie zależny od podanych argumentów wywołania programu:
exit: exitcode=atoi(argv[1]=0): exitcode=0
exit: exit(exitcode=0): call...
0

exit: exitcode=atoi(argv[1]=1): exitcode=1
exit: exit(exitcode=1): call...
1

exit: exitcode=atoi(argv[1]=2): exitcode=2
exit: exit(exitcode=2): call...
2
Aby dostrzec rezultat należy uważniej przyjrzeć się kodu źródłowemu programu, po wywołaniu funkcji exit(exitcode); znajduje się jeszcze wywołanie funkcji printf();, który nie zostaje wykonany, gdyż działanie programu kończy się w momencie wywołania wcześniejszej funkcji exit(exitcode);, powyższy kod źródłowy dobrze to obrazuje.



#top getenv


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji getenv() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji getenv() jest następująca:
/* Return the value of envariable NAME, or NULL if it doesn't exist.  */
extern char *getenv (__const char *__name) __THROW __nonnull ((1)) __wur;

Powiązane:
environ, clearenv(), getenv(), putenv(), setenv(), unsetenv(),

Opis:
Funkcja getenv() przegląda zmienne środowiskowe dostępne dla danego procesu w poszukiwaniu zmiennej środowiskowej o podanej nazwie. W przypadku kiedy zmienna środowiskowa zostanie znaleziona zwracany jest wskaźnik do wartości zmiennej środowiskowej o podanej nazwie. Jeśli zmienna środowiskowa nie zostanie znaleziona zwracana jest wartość NULL.

Argumenty:
const char *__name - nazwa poszukiwanej zmiennej środowiskowej.

Zwracana wartość:
char * - wskaźnik do wartości zmiennej środowiskowej (NULL w przypadku kiedy zmienna środowiskowa nie zostanie znaleziona).

Example:
zawartość pliku getenv.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */



int main(int argc, char **argv) {
	char *self;
	char *envval;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<2) {
		printf("Usage: %s <envname>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s USER\n", argv[0]);
		printf("       %s HOME\n", argv[0]);
		printf("       %s PATH\n", argv[0]);
		return 0;
	}
	
	envval=getenv(argv[1]);
	printf("%s: envval=getenv(argv[1]=%s): envval=|%s|\n", self, argv[1], envval);
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/getenv
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/misc/getenv <envname>
Examples:
       /home/local/code/ansiccode/misc/getenv USER
       /home/local/code/ansiccode/misc/getenv HOME
       /home/local/code/ansiccode/misc/getenv PATH

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/getenv USER
/home/local/code/ansiccode/misc/getenv HOME
/home/local/code/ansiccode/misc/getenv PATH
rezultat będzie zależny od podanych argumentów wywołania programu:
getenv: envval=getenv(argv[1]=USER): envval=|user|

getenv: envval=getenv(argv[1]=HOME): envval=|/home/user|

getenv: envval=getenv(argv[1]=PATH): envval=|/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/usr/X11R6/sbin:/home/local/sbin:/home/local/bin|



#top getopt


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji getopt() znajduje się w pliku nagłówkowym getopt.h.
Deklaracja funkcji getopt() jest następująca:
#ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
   differences in the consts, in stdlib.h.  To avoid compilation
   errors, only prototype getopt for the GNU C library.  */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
       __THROW;
#else /* not __GNU_LIBRARY__ */
extern int getopt ();
#endif /* __GNU_LIBRARY__ */

Powiązane:
getopt(), getopt_long(), getopt_long_only(),

Opis:
Funkcja getopt()

Argumenty:
int ___argc -
char *const *___argv -
const char *__shortopts -

Zwracana wartość:
int -

Example:
zawartość pliku getopt.c
SELECT ALL


program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:

program wyświetli informacje o sposobie uruchamiania programu:


jako argument wywołania programu można podać analogiczne jak poniżej argumenty:

rezultat będzie zależny od podanych argumentów wywołania programu:




#top getopt_long


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji getopt_long() znajduje się w pliku nagłówkowym getopt.h.
Deklaracja funkcji getopt_long() jest następująca:
extern int getopt_long (int ___argc, char *const *___argv,
            const char *__shortopts,
                const struct option *__longopts, int *__longind)
       __THROW;

Powiązane:
getopt(), getopt_long(), getopt_long_only(),

Opis:
Funkcja getopt_long()

Argumenty:
int ___argc -
char *const *___argv -
const char *__shortopts -
const struct option *__longopts -
int *__longind -

Zwracana wartość:
int -



#top getopt_long_only


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji getopt_long_only() znajduje się w pliku nagłówkowym getopt.h.
Deklaracja funkcji getopt_long_only() jest następująca:
extern int getopt_long_only (int ___argc, char *const *___argv,
                 const char *__shortopts,
                     const struct option *__longopts, int *__longind)
       __THROW;

Powiązane:
getopt(), getopt_long(), getopt_long_only(),

Opis:
Funkcja getopt_long_only()

Argumenty:
int ___argc -
char *const *___argv -
const char *__shortopts -
const struct option *__longopts -
int *__longind -

Zwracana wartość:
int -



#top getrlimit


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji getrlimit() znajduje się w pliku nagłówkowym sys/resource.h.
Deklaracja funkcji getrlimit() jest następująca:
/* Put the soft and hard limits for RESOURCE in *RLIMITS.
   Returns 0 if successful, -1 if not (and sets errno).  *:
extern int getrlimit (__rlimit_resource_t __resource,
              struct rlimit *__rlimits) __THROW;

Powiązane:
getrlimit(), getrusage(), setrlimit(),

Opis:
Funkcja getrlimit() pobiera limity konsumpcji różnych zasobów systemowych dla danego procesu. Limity zasobów reprezentowane są przez strukturę rlimit. Pole rlim_cur określa "miękki" limit danego zasobu dla procesu, rlim_max określa "twardy" (maksymalny) limit danego zasobu dla procesu.

Argumenty:
__rlimit_resource_t __resource - Określa rodzaj pobieranego limitu dla zasobu. Następujące rodzaje zasobów są zdefiniowane:
RLIMIT_CPU - Maksymalna wartość czasu wykorzystania procesora (w sekundach). Jeśli limit zostanie przekroczony do procesy zostanie wysłany sygnał SIGXCPU. Jeśli proces przechwytuje:ingoruje sygnał SIGXCPU lub jeśli wszystkie wątki procesu blokują sygnał SIGXCPU zachowanie jest nieokreślone.
RLIMIT_FSIZE - Maksymalna wielkość pliku możliwa do utworzenia przez proces (w bajtach). Jeśli operacja zapisu lub przycinania spowoduje przekroczenie limitu, sygnał SIGXFSZ zostanie wygenerowany dla procesu:wątku. Jeśli proces/wątki przechwytują lub blokują sygnał SIGXFSZ, kontynuacja prowadząca do zwiększenia rozmiaru pliku powyżej limitu zakończy się błędem oraz zostanie ustawiona globalna zmienna errno na [EFBIG].
RLIMIT_DATA - Maksymalna wielkość danych dla procesu (w bajtach). Jeśli limit zostanie przekroczony funkcja malloc() zwraca błąd oraz zostaje ustawiona globalna zmienna errno na [ENOMEM].
RLIMIT_STACK - Maksymalny rozmiar stosu dla procesu (w bajtach). Jeśli limit zostanie przekroczony do procesu wysyłany jest sygnał SIGSEGV. Jeśli wątki procesu blokują sygnał SIGSEGV lub proces ignoruje:przechwytuje sygnał SIGSEGV i nie wprowadza zmian prowadzących do używnia alternatywnego stosu, obsługa sygnału SIGSEGV zostanie ustawiona na SIG_DFL zanim sygnał zostanie wygenerowany.
RLIMIT_CORE - Maksymalny rozmiar pliku "zrzutu rdzenia", jaki może zostać utworzony przez proces (w bajtach). Limit ustawiony na 0 zapobiega tworzeniu pliku "zrzutu rdzenia". Jeśli limit zostanie przekroczony zapis do pliku "zrzutu rdzenia" jest przerywany przy tej wartości.
RLIMIT_RSS - Maksymalny rozmiar pamięci rezydentnej dla procesu. Jeśli limit zostanie przekroczony strony pamięci używane najdawniej będą przenoszone do pamięci swap.
RLIMIT_NOFILE - Maksymalna ilość deskryptorów możliwa do utworzonia przez proces. Jeśli limit zostanie przekroczony próba utworzenia nowego deskryptora zakończy się błędem oraz zostanie ustawiona globalna zmienna errno na [EMFILE].
RLIMIT_AS - Maksymalny rozmiar pamięci dostępnej dla procesu (w bajtach). Jeśli limit zostanie przekroczony funkcja malloc() i mmap() zwrócą błąd oraz zostanie ustawiona globalna zmienna errno na [ENOMEM].
RLIMIT_NPROC - Maksymalna liczba procesów, które użytkownik może uruchomić. Jeśli limit zostanie przekroczony
RLIMIT_MEMLOCK - Maksymalny rozmiar pamięci, która może zostać zablokowana przez funkcja mlock() i mlockall().
RLIMIT_LOCKS - Maksymalna ilość blokać, które proces może utworzyć przez funkcje flock() i fcntl().
RLIMIT_SIGPENDING - Maksymalna ilość sygnałów oczekujących w kolejce do obsłużenia przez proces.
RLIMIT_MSGQUEUE - Maksymalny rozmiar wiadomości w kolejce POSIX.
RLIMIT_NICE - Maksymalny wartość priorytetu dla procesu. Poziomy 19 ... -20 odpowiadają wartościom 0 .. 39 limitu tego zasobu.
RLIMIT_RTPRIO - Maksymalny priorytet realtime dozwolony dla nieuprzywilejowanych procesów.
RLIMIT_NLIMITS - limit
struct rlimit *__rlimits - wskaźnik do struktury rlimit, w której pola rlim_cur oraz rlim_max określają limit "miękki" i "twardy" dla danego zasobu.

Zwracana wartość:
int - w przypadku sukcesu odczytania limitów zasobów zwracana jest wartość 0 oraz ustawiane są w strukturze przekazanej jako wskaźnik, w przypadku niepowodzenia zwracana jest wartość -1 oraz ustawiana globalna zmienna errno zawierająca powód występienia błędu.

Example:
zawartość pliku getrlimit.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <errno.h>         /* for errno constant, error constants, */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
#include <sys/resource.h>  /* for id_t, __rlimit_resource_t, __rusage_who_t, __priority_which_t, getrlimit(), setrlimit(), getrusage(), getpriority(), setpriority(), */
#endif



int main(int argc, char **argv) {
	char *self;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	int result;
	struct rlimit rlimits;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<2) {
		printf("Usage: %s <exitcode>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s\n", argv[0]);
		printf("       %s\n", argv[0]);
		printf("       %s\n", argv[0]);
		return 0;
	}
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* getrlimit() is not available on this OS platform !!! */
	printf("%s: getrlimit() is not available on this OS platform !!!\n", self);
	/* setrlimit() is not available on this OS platform !!! */
	printf("%s: setrlimit() is not available on this OS platform !!!\n", self);
#else
	memset(&rlimits, 0x00, sizeof(struct rlimit));
	printf("%s: result=getrlimit(RLIMIT_FSIZE=%d, &rlimits={%ld, %ld}):\n", self, RLIMIT_FSIZE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max);
	result=getrlimit(RLIMIT_FSIZE, &rlimits);
	if (result>=0) printf("%s: result=getrlimit(RLIMIT_FSIZE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): Successful getrlimit().\n", self, RLIMIT_FSIZE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result);
	else           printf("%s: result=getrlimit(RLIMIT_FSIZE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): else: Unable to getrlimit(), Reason: %d:%s\n", self, RLIMIT_FSIZE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result, errno, strerror(errno));
	
	rlimits.rlim_cur = 65535;
	rlimits.rlim_max = 65535;
	printf("%s: result=setrusage(RLIMIT_FSIZE=%d, &rlimits={%ld, %ld}):\n", self, RLIMIT_FSIZE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max);
	result=setrlimit(RLIMIT_FSIZE, &rlimits);
	if (result>=0) printf("%s: result=setrlimit(RLIMIT_FSIZE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): Successful setrusage().\n", self, RLIMIT_FSIZE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result);
	else           printf("%s: result=setrlimit(RLIMIT_FSIZE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): else: Unable to setrusage(), Reason: %d:%s\n", self, RLIMIT_FSIZE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result, errno, strerror(errno));
	
	printf("%s: result=getrlimit(RLIMIT_FSIZE=%d, &rlimits):\n", self, RLIMIT_FSIZE);
	result=getrlimit(RLIMIT_FSIZE, &rlimits);
	if (result>=0) printf("%s: result=getrlimit(RLIMIT_FSIZE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): Successful getrlimit().\n", self, RLIMIT_FSIZE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result);
	else           printf("%s: result=getrlimit(RLIMIT_FSIZE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): else: Unable to getrlimit(), Reason: %d:%s\n", self, RLIMIT_FSIZE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result, errno, strerror(errno));
	printf("%s:\n", self);
	
	
	
	memset(&rlimits, 0x00, sizeof(struct rlimit));
	printf("%s: result=getrlimit(RLIMIT_NOFILE=%d, &rlimits={%ld, %ld}):\n", self, RLIMIT_NOFILE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max);
	result=getrlimit(RLIMIT_NOFILE, &rlimits);
	if (result>=0) printf("%s: result=getrlimit(RLIMIT_NOFILE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): Successful getrlimit().\n", self, RLIMIT_NOFILE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result);
	else           printf("%s: result=getrlimit(RLIMIT_NOFILE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): else: Unable to getrlimit(), Reason: %d:%s\n", self, RLIMIT_NOFILE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result, errno, strerror(errno));
	
	rlimits.rlim_cur = 65535;
	rlimits.rlim_max = 65535;
	printf("%s: result=setrusage(RLIMIT_NOFILE=%d, &rlimits={%ld, %ld}):\n", self, RLIMIT_NOFILE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max);
	result=setrlimit(RLIMIT_NOFILE, &rlimits);
	if (result>=0) printf("%s: result=setrlimit(RLIMIT_NOFILE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): Successful setrusage().\n", self, RLIMIT_NOFILE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result);
	else           printf("%s: result=setrlimit(RLIMIT_NOFILE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): else: Unable to setrusage(), Reason: %d:%s\n", self, RLIMIT_NOFILE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result, errno, strerror(errno));
	
	memset(&rlimits, 0x00, sizeof(struct rlimit));
	printf("%s: result=getrlimit(RLIMIT_NOFILE=%d, &rlimits={%ld, %ld}):\n", self, RLIMIT_NOFILE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max);
	result=getrlimit(RLIMIT_NOFILE, &rlimits);
	if (result>=0) printf("%s: result=getrlimit(RLIMIT_NOFILE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): Successful getrlimit().\n", self, RLIMIT_NOFILE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max, result);
	else           printf("%s: result=getrlimit(RLIMIT_NOFILE=%d, &rlimits={%ld, %ld}): result=%d if (result>=0): else: Unable to getrlimit(), Reason: %d:%s\n", self, RLIMIT_NOFILE, (long int)rlimits.rlim_cur, (long int)rlimits.rlim_max,  result, errno, strerror(errno));
	printf("%s:\n", self);
#endif
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/getrlimit
program wyświetli stosowne informacje o sposobie działania:
getrlimit: result=getrlimit(RLIMIT_FSIZE=1, &rlimits={0, 0}):
getrlimit: result=getrlimit(RLIMIT_FSIZE=1, &rlimits={-1, -1}): result=0 if (result>=0): Successful getrlimit().
getrlimit: result=setrlimit(RLIMIT_FSIZE=1, &rlimits={65535, 65535}):
getrlimit: result=setrlimit(RLIMIT_FSIZE=1, &rlimits={65535, 65535}): result=0 if (result>=0): Successful setrlimit().
getrlimit: result=getrlimit(RLIMIT_FSIZE=1, &rlimits):
getrlimit: result=getrlimit(RLIMIT_FSIZE=1, &rlimits={65535, 65535}): result=0 if (result>=0): Successful getrlimit().
getrlimit:
getrlimit: result=getrlimit(RLIMIT_NOFILE=7, &rlimits={0, 0}):
getrlimit: result=getrlimit(RLIMIT_NOFILE=7, &rlimits={1024, 1024}): result=0 if (result>=0): Successful getrlimit().
getrlimit: result=setrlimit(RLIMIT_NOFILE=7, &rlimits={65535, 65535}):
getrlimit: result=setrlimit(RLIMIT_NOFILE=7, &rlimits={65535, 65535}): result=-1 if (result>=0): else: Unable to setrlimit(), Reason: 1:Operation not permitted
getrlimit: result=getrlimit(RLIMIT_NOFILE=7, &rlimits={0, 0}):
getrlimit: result=getrlimit(RLIMIT_NOFILE=7, &rlimits={1024, 1024}): result=0 if (result>=0): Successful getrlimit().
getrlimit:



#top getrusage


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji getrusage() znajduje się w pliku nagłówkowym sys/resource.h.
Deklaracja funkcji getrusage() jest następująca:
/* Return resource usage information on process indicated by WHO
   and put it in *USAGE.  Returns 0 for success, -1 for failure.  */
extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;

Powiązane:
getrlimit(), getrusage(), setrlimit(),

Opis:
Funkcja getrusage() zwraca bieżące użycie zasobów dla procesu (wywołanie z argumentem __who=RUSAGE_SELF) lub dla procesów potomnych (wywołanie z argumentem __who=RUSAGE_CHILDREN).

Argumenty:
__rusage_who_t __who - Dla wartości argumentu __who na:
RUSAGE_SELF - zwracane wartości zużycia zasobów dotyczą bieżącego procesu
RUSAGE_CHILDREN - zwracane wartości zużycia zasobów dotyczą procesów potomnych (zarówno procesów, na których zakończenie oczekuje bieżący proces jak również już zakończonych) bieżącego procesu
struct rusage *__usage - Wskaźnik do struktury zawierającej po wywołaniu informacje dotyczące zużycia zasobów.

Zwracana wartość:
int - W przypadku sukcesu zwracana jest wartość 0 oraz strutura przekazana jako wskaźnik zawiera informacje dotyczące zużycia zasobów, w przypadku niepowodzenia zwracana jest wartość -1 oraz ustawiana globalna zmienna errno zawierająca powód wystąpienia błędu.

Example:
zawartość pliku getrusage.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <unistd.h>        /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */
                           /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(), getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */
                           /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */
#include <errno.h>         /* for errno constant, error constants, */

#if defined(HAVE_GETRUSAGE)
#include <sys/resource.h>  /* for id_t, __rlimit_resource_t, __rusage_who_t, __priority_which_t, getrlimit(), setrlimit(), getrusage(), getpriority(), setpriority(), */
#endif



int main(int argc, char **argv) {
	char *self;
#if defined(HAVE_GETRUSAGE)
	struct rusage usages;
	struct timeval start, end;
	int result;
	int i, j;
	double k = 0;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", argv[0]);
		return 0;
	}
	
#if defined(HAVE_GETRUSAGE)
	memset(&usages, 0x00, sizeof(struct rusage));
	result=getrusage(RUSAGE_SELF, &usages);
	start = usages.ru_stime;
	if (result>=0) printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): result=%d if (result>=0): Successful getrusage().\n", self, RUSAGE_SELF, result);
	else           printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): result=%d if (result>=0): else: Unable to getrusage(), Reason: %d:%s\n", self, RUSAGE_SELF, result, errno, strerror(errno));
	
	for (i=0; i<10000; i++) {
		/* Double loop for more interesting results. */
		for (j=0; j<10000; j++) {
			k=k*1.5;
		}
	}
	
	result=getrusage(RUSAGE_SELF, &usages);
	end = usages.ru_stime;
	if (result>=0) {
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_utime={%ld, %ld}\n", self, RUSAGE_SELF, (long int)usages.ru_utime.tv_sec, usages.ru_utime.tv_usec);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_stime={%ld, %ld}\n", self, RUSAGE_SELF, (long int)usages.ru_stime.tv_sec, usages.ru_stime.tv_usec);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_maxrss=%ld\n", self, RUSAGE_SELF, usages.ru_maxrss);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_ixrss=%ld\n", self, RUSAGE_SELF, usages.ru_ixrss);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_idrss=%ld\n", self, RUSAGE_SELF, usages.ru_idrss);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_isrss=%ld\n", self, RUSAGE_SELF, usages.ru_isrss);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_minflt=%ld\n", self, RUSAGE_SELF, usages.ru_minflt);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_majflt=%ld\n", self, RUSAGE_SELF, usages.ru_majflt);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_nswap=%ld\n", self, RUSAGE_SELF, usages.ru_nswap);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_inblock=%ld\n", self, RUSAGE_SELF, usages.ru_inblock);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_oublock=%ld\n", self, RUSAGE_SELF, usages.ru_oublock);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_msgsnd=%ld\n", self, RUSAGE_SELF, usages.ru_msgsnd);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_msgrcv=%ld\n", self, RUSAGE_SELF, usages.ru_msgrcv);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_nsignals=%ld\n", self, RUSAGE_SELF, usages.ru_nsignals);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_nvcsw=%ld\n", self, RUSAGE_SELF, usages.ru_nvcsw);
		printf("%s: result=getrusage(RUSAGE_SELF=%d, &usages): usages.ru_nivcsw=%ld\n", self, RUSAGE_SELF, usages.ru_nivcsw);
		printf("%s: Started at: %ld.%lds\n", self, (long int)start.tv_sec, start.tv_usec);
		printf("%s: Ended   at: %ld.%lds\n", self, (long int)end.tv_sec,   end.tv_usec  );
	}
#else
	/* getrusage() is not available on this OS platform !!! */
	printf("%s: getrusage() is not available on this OS platform !!!\n", self);
#endif
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/getrusage
program wyświetli stosowne informacje o sposobie działania:
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): result=0 if (result>=0): Successful getrusage().
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_utime={0, 999}
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_stime={0, 0}
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_maxrss=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_ixrss=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_idrss=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_isrss=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_minflt=135
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_majflt=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_nswap=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_inblock=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_oublock=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_msgsnd=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_msgrcv=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_nsignals=0
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_nvcsw=1
getrusage: result=getrusage(RUSAGE_SELF=0, &usages): usages.ru_nivcsw=1
getrusage: Started at: 0.999s
getrusage: Ended   at: 0.999s



#top nanosleep


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji nanosleep() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji nanosleep() jest następująca:
/* Pause execution for a number of nanoseconds.

   This function is a cancellation point and therefore not marked with
   __THROW.  */
extern int nanosleep (__const struct timespec *__requested_time,
              struct timespec *__remaining);

Powiązane:
nanosleep(), sleep(), usleep(),

Opis:
Funkcja nanosleep() powoduje zatrzymanie (uśpienie, opóźnienie) wykonywania bieżącego procesu do upłynięcia zadanego czasu. Funkcja nanosleep() może zakończyć działanie wcześniej jeśli do procesu zostanie wysłany sygnał, który nie jest przez proces ignorowany. W takim przypadku zwracana jest wartość -1 oraz ustawiana jest globalna zmienna errno na wartość EINTR oraz w zmiennej __remaining zwracana jest wartość czasu jaka pozostała (w przypadku gdy wskaźnik nie jest NULL). Zmienna __remaining może zostać użyta do ponownego wywołania funkcji nanosleep() w celu kontynuowania przerwanej przerwy.

Argumenty:
const struct timespec __requested_time - Czas na jaki należy zatrzymać (uśpić opóźnić) wykonywanie procesu.
struct timespec __remaining - Czas jaki pozostał do zakończenia ustawionej przerwy w przypadku odebrania sygnału, który przez proces nie został zignorowany.

Zwracana wartość:
int - W przypadku sukcesu (zakończenia przerwy w działaniu programu bez przeszkód) zwracana jest wartość 0, w przeciwnym przypadku zwracana jest wartość -1 oraz ustawiana globalna zmienna errno określająca powód wystąpienia błędu.



#top on_exit


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji on_exit() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji on_exit() jest następująca:
/* Register a function to be called with the status
   given to `exit' and the given argument.  *:
extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
     __THROW __nonnull ((1));

Powiązane:
EXIT_FAILURE, EXIT_SUCCESS, abort(), atexit(), exit(), on_exit(),

Opis:
Funkcja on_exit() funkcje, które wywoływane w przypadku prawidłowego zakończenia programu. W przypadku normalnego zakończenia programu funkcje wywoływane są w odwrotnej kolejności w której zostały zarejestrowane. Ostatnio zarejestrowana funkcja w przypadku prawidłowego zakończenia programu zostanie wywołana jako pierwsza.

Argumenty:
void (*__func) (int __status, void *__arg) - wskaźnik do funkcji (funkcja przyjmuje dwa argumenty: wartość numeryczną zwracaną przez program przy zakończeniu (wartość zwracana jako return w funkcji main() lub wartość podaną jako argument wywołania funkcji exit) i wskaźnik do argumentu przekazywanego do rejestrowanej funkcji oraz nie zwracająca żadnych wartości) która zostanie wywołana w przypadku normalnego zakończenia programu.

Zwracana wartość:
int - w przypadku poprawnej rejestracji funkcji zwracana jest wartość 0, w przeciwym przypadku zwracana jest nie zerowa wartość.

Example:
zawartość pliku on_exit1.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <errno.h>         /* for errno constant, error constants, */



void onexitfn1(int status, void *arg) {
	char *strarg=(char*)arg;
	printf("onexitfn1(int status=%d, void *arg=%s)\n", status, strarg);
}



void onexitfn2(int status, void *arg) {
	char *strarg=(char*)arg;
	printf("onexitfn2(int status=%d, void *arg=%s)\n", status, strarg);
}



int main(int argc, char **argv) {
	char *self;
#if defined(HAVE_ONEXIT)
	int exitcode;
	int result;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<4) {
		printf("Usage: %s <exittype=0|1> <exitcode=0..255> \"example text\"\n", argv[0]);
		printf("Examples:\n");
		printf("       %s 0 0 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 0 1 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 0 2 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 1 0 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 1 1 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 1 2 \"example text\"; echo $?\n", argv[0]);
		return 0;
	}
	
#if defined(HAVE_ONEXIT)
	result=on_exit(&onexitfn1, argv[3]);
	if (result>=0) printf("%s: result=on_exit(&onexitfn1, strarg=%s): result=%d if (result>=0): Successful on_exit().\n", self, argv[3], result);
	else           printf("%s: result=on_exit(&onexitfn1, strarg=%s): result=%d if (result>=0): else: Unable to on_exit(), Reason: %d:%s\n", self, argv[3], result, errno, strerror(errno));
	result=on_exit(&onexitfn2, argv[3]);
	if (result>=0) printf("%s: result=on_exit(&onexitfn2, strarg=%s): result=%d if (result>=0): Successful on_exit().\n", self, argv[3], result);
	else           printf("%s: result=on_exit(&onexitfn2, strarg=%s): result=%d if (result>=0): else: Unable to on_exit(), Reason: %d:%s\n", self, argv[3], result, errno, strerror(errno));
#else
	/* on_exit() is not available on this OS platform !!! */
	printf("%s: on_exit() is not available on this OS platform !!!\n", argv[0]);
#endif
	
	if (strncmp(argv[1],"1",strlen("1"))==0) {
		exit(atoi(argv[2]));
	} else {
	return atoi(argv[2]);
	}
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/on_exit1
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/misc/on_exit1 <exittype=0|1> <exitcode=0..255> "example text"
Examples:
       /home/local/code/ansiccode/misc/on_exit1 0 0 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit1 0 1 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit1 0 2 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit1 1 0 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit1 1 1 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit1 1 2 "example text"; echo $?

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/on_exit1 0 0 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit1 0 1 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit1 0 2 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit1 1 0 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit1 1 1 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit1 1 2 "example text"; echo $?
rezultat będzie zależny od podanych argumentów wywołania programu:
on_exit1: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit1: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn2(int status=0, void *arg=example text)
onexitfn1(int status=0, void *arg=example text)
0

on_exit1: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit1: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn2(int status=1, void *arg=example text)
onexitfn1(int status=1, void *arg=example text)
1

on_exit1: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit1: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn2(int status=2, void *arg=example text)
onexitfn1(int status=2, void *arg=example text)
2

on_exit1: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit1: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn2(int status=0, void *arg=example text)
onexitfn1(int status=0, void *arg=example text)
0

on_exit1: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit1: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn2(int status=1, void *arg=example text)
onexitfn1(int status=1, void *arg=example text)
1

on_exit1: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit1: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn2(int status=2, void *arg=example text)
onexitfn1(int status=2, void *arg=example text)
2

Example:
zawartość pliku on_exit2.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <errno.h>         /* for errno constant, error constants, */



void onexitfn1(int status, void *arg) {
	char *strarg=(char*)arg;
	printf("onexitfn1(int status=%d, void *arg=%s)\n", status, strarg);
}



void onexitfn2(int status, void *arg) {
	char *strarg=(char*)arg;
	printf("onexitfn2(int status=%d, void *arg=%s)\n", status, strarg);
}



int main(int argc, char **argv) {
	char *self;
#if defined(HAVE_ONEXIT)
	int exitcode;
	int result;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<4) {
		printf("Usage: %s <exittype=0|1> <exitcode=0..255> \"example text\"\n", argv[0]);
		printf("Examples:\n");
		printf("       %s 0 0 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 0 1 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 0 2 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 1 0 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 1 1 \"example text\"; echo $?\n", argv[0]);
		printf("       %s 1 2 \"example text\"; echo $?\n", argv[0]);
		return 0;
}

#if defined(HAVE_ONEXIT)
	result=on_exit(&onexitfn2, argv[3]);
	if (result>=0) printf("%s: result=on_exit(&onexitfn2, strarg=%s): result=%d if (result>=0): Successful on_exit().\n", self, argv[3], result);
	else           printf("%s: result=on_exit(&onexitfn2, strarg=%s): result=%d if (result>=0): else: Unable to on_exit(), Reason: %d:%s\n", self, argv[3], result, errno, strerror(errno));
	result=on_exit(&onexitfn1, argv[3]);
	if (result>=0) printf("%s: result=on_exit(&onexitfn1, strarg=%s): result=%d if (result>=0): Successful on_exit().\n", self, argv[3], result);
	else           printf("%s: result=on_exit(&onexitfn1, strarg=%s): result=%d if (result>=0): else: Unable to on_exit(), Reason: %d:%s\n", self, argv[3], result, errno, strerror(errno));
#else
	/* on_exit() is not available on this OS platform !!! */
	printf("%s: on_exit() is not available on this OS platform !!!\n", argv[0]);
#endif

	if (strncmp(argv[1],"1",strlen("1"))==0) {
		exit(atoi(argv[2]));
	} else {
		return atoi(argv[2]);
	}
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/on_exit2
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/misc/on_exit2 <exittype=0|1> <exitcode=0..255> "example text"
Examples:
       /home/local/code/ansiccode/misc/on_exit2 0 0 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit2 0 1 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit2 0 2 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit2 1 0 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit2 1 1 "example text"; echo $?
       /home/local/code/ansiccode/misc/on_exit2 1 2 "example text"; echo $?

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/on_exit2 0 0 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit2 0 1 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit2 0 2 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit2 1 0 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit2 1 1 "example text"; echo $?
/home/local/code/ansiccode/misc/on_exit2 1 2 "example text"; echo $?
rezultat będzie zależny od podanych argumentów wywołania programu:
on_exit2: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit2: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn1(int status=0, void *arg=example text)
onexitfn2(int status=0, void *arg=example text)
0

on_exit2: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit2: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn1(int status=1, void *arg=example text)
onexitfn2(int status=1, void *arg=example text)
1

on_exit2: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit2: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn1(int status=2, void *arg=example text)
onexitfn2(int status=2, void *arg=example text)
2

on_exit2: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit2: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn1(int status=0, void *arg=example text)
onexitfn2(int status=0, void *arg=example text)
0

on_exit2: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit2: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn1(int status=1, void *arg=example text)
onexitfn2(int status=1, void *arg=example text)
1

on_exit2: result=on_exit(&onexitfn2, strarg=example text): result=0 if (result>=0): Successful on_exit().
on_exit2: result=on_exit(&onexitfn1, strarg=example text): result=0 if (result>=0): Successful on_exit().
onexitfn1(int status=2, void *arg=example text)
onexitfn2(int status=2, void *arg=example text)
2



#top pause


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji pause() znajduje się w pliku nagłówkowym unistd.h.
Deklaracja funkcji pause() jest następująca:
/* Suspend the process until a signal arrives.
   This always returns -1 and sets `errno' to EINTR.

   This function is a cancellation point and therefore not marked with
   __THROW.  */
extern int pause (void);

Powiązane:

Opis:
Funkcja pause() powoduje zatrzymanie (uśpienie, opóźnienie) wykonywania bieżącego procesu do czasu odebrania sygnału.

Argumenty:
Funkcja nie przyjmuje żadnych argumentów.

Zwracana wartość:
int - funkcja kończy działanie tylko po odebraniu sygnału, wtedy zwraca wartość -1 oraz ustawia globalną zmienną errno na wartość EINTR.

Example:
zawartość pliku pause1.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <unistd.h>        /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */
                           /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */
                           /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */
#include <errno.h>         /* for errno constant, error constants, */

#include <signal.h>        /* for SIGHUP, SIGINT, SIGQUIT, SIG_DFL, SIG_ERR, signal(), kill(), killpg(), raise(), psignal(), sigpause(), sigblock(), sigsetmask(), siggetmask(), sighandler_t, sig_t, */



volatile int sig_caught = 0;

void sig_handler(int sig_arg) {
	sig_caught = sig_arg;
}



int main(int argc, char **argv) {
	char *self;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	int result;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", argv[0]);
		return 0;
	}
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* pause() is not available on this OS platform !!! */
	printf("%s: pause() is not available on this OS platform !!!\n", argv[0]);
#else
	signal(SIGCONT, sig_handler);
	printf("%s: Calling pause() and waiting for signal: SIGCONT = %d:%s\n", self, SIGCONT, strsignal(SIGCONT));
	result=pause();
	printf("%s: Caught signal: %d:%s\n", self, sig_caught, strsignal(sig_caught));
	printf("%s: result=pause(); result=%d Return from pause(), Reason=%d:%s\n", self, result, errno, strerror(errno));
#endif
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/pause1
program wyświetli stosowne informacje o sposobie działania:
pause1: Calling pause() and waiting for signal: SIGCONT = 18:Continued

Aby zrozumieć działanie funkcji pause() należy uruchomić drugą (dodatkową okno/zakładkę) z konsolą wysłać do programu sygnał SIGCONT poleceniem kill.
kill -SIGCONT `pidof pause1`
uruchomiony program zatrzymany w funkcji pause() w oczekiwaniu na sygnał SIGCONT po odebraniu oczekiwanego sygnału wyświetli następujące informacje (oraz zakończy swoje działanie):
pause1: Caught signal: 18:Continued
pause1: result=pause(); result=-1 Return from pause(), Reason=4:Interrupted system call

Example:
zawartość pliku pause2.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <unistd.h>        /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */
                           /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */
                           /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */
#include <errno.h>         /* for errno constant, error constants, */
#include <signal.h>



void ALARMhandler(int signum) {
	printf("ALARMhandler(int signum=%d)\n", signum);
}

int main(int argc, char **argv) {
	char *self;
	int result;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", argv[0]);
		return 0;
	}
	
	result=0;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* pause() is not available on this OS platform !!! */
	printf("%s: pause() is not available on this OS platform !!!\n", self);
#else
	signal(SIGALRM, ALARMhandler);
	printf("%s: result=alarm(3):\n", self);
	result=alarm(3);
	printf("%s: result=alarm(3): result=%d\n", self, result);
	
	printf("%s: result=pause():\n", self);
	result=pause();
	if (result>=0) printf("%s: result=pause(): result=%d if (result>=0): Successful pause()\n", self, result);
	else           printf("%s: result=pause(): result=%d if (result>=0): else: pause interupted, Reason: %d:%s\n", self, result, errno, strerror(errno));
#endif
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/pause2
program wyświetli stosowne informacje o sposobie działania:
pause2: result=alarm(3):
pause2: result=alarm(3): result=0
pause2: result=pause():
ALARMhandler(int signum=14)
pause2: result=pause(): result=-1 if (result>=0): else: pause interupted, Reason: 4:Interrupted system call



#top perror


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji perror() znajduje się w pliku nagłówkowym stdio.h.
Deklaracja funkcji perror() jest następująca:
/* Print a message describing the meaning of the value of errno.

   This function is a possible cancellation point and therefore not
   marked with __THROW.  */
extern void perror (__const char *__s);

Powiązane:
errno, perror(), strerror(),

Opis:
Funkcja perror() wyświetla informację tekstową dotyczącą kodu błędu ustawionego w errno.

Argumenty:
const char *__s - łańcuch znaków który zostanie wyświetlony wraz z dwukropkiem poprzedzając wyświetlaną informację dotyczącą błędu.

Zwracana wartość:
Funkcja nie zwraca żadnej wartości.

Example:
zawartość pliku perror.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <errno.h>         /* for errno constant, error constants, */



int main(int argc, char **argv) {
	char *self;
	int errarg;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<2) {
		printf("Usage: %s <errno-num>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s 0\n", argv[0]);
		printf("       %s 1\n", argv[0]);
		printf("       %s 2\n", argv[0]);
		printf("       %s 3\n", argv[0]);
		printf("       %s 4\n", argv[0]);
		printf("       %s 5\n", argv[0]);
		return 0;
	}
	
	errarg=atoi(argv[1]);
	errno=errarg;
	printf("%s perror(self=%s): CALL\n", argv[0], self);
	perror(self);
	printf("%s perror(self=%s): END\n", argv[0], self);
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/perror
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/misc/perror <errno-num>
Examples:
       /home/local/code/ansiccode/misc/perror 0
       /home/local/code/ansiccode/misc/perror 1
       /home/local/code/ansiccode/misc/perror 2
       /home/local/code/ansiccode/misc/perror 3
       /home/local/code/ansiccode/misc/perror 4
       /home/local/code/ansiccode/misc/perror 5

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/perror 0
/home/local/code/ansiccode/misc/perror 1
/home/local/code/ansiccode/misc/perror 2
/home/local/code/ansiccode/misc/perror 3
/home/local/code/ansiccode/misc/perror 4
/home/local/code/ansiccode/misc/perror 5
rezultat będzie zależny od podanych argumentów wywołania programu:
/home/local/code/ansiccode/misc/perror perror(self=perror): CALL
perror: Success
/home/local/code/ansiccode/misc/perror perror(self=perror): END

/home/local/code/ansiccode/misc/perror perror(self=perror): CALL
perror: Operation not permitted
/home/local/code/ansiccode/misc/perror perror(self=perror): END

/home/local/code/ansiccode/misc/perror perror(self=perror): CALL
perror: No such file or directory
/home/local/code/ansiccode/misc/perror perror(self=perror): END

/home/local/code/ansiccode/misc/perror perror(self=perror): CALL
perror: No such process
/home/local/code/ansiccode/misc/perror perror(self=perror): END

/home/local/code/ansiccode/misc/perror perror(self=perror): CALL
perror: Interrupted system call
/home/local/code/ansiccode/misc/perror perror(self=perror): END

/home/local/code/ansiccode/misc/perror perror(self=perror): CALL
perror: Input/output error
/home/local/code/ansiccode/misc/perror perror(self=perror): END
Jak widać na powyższym rezultacie wywołania programu, funkcja perror() nie kończy działania programu ani nie zwraca odpowiedniego kodu zakończenia programu. Zakończyć program wraz z opdowidnim kodem informującym o przyczynie błędu jest zobowiązany autor programu.



#top putenv


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji putenv() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji putenv() jest następująca:
* The SVID says this is in <stdio.h>, but this seems a better place.   */
/* Put STRING, which is of the form "NAME=VALUE", in the environment.
   If there is no `=', remove NAME from the environment.  */
extern int putenv (char *__string) __THROW __nonnull ((1));

Powiązane:
environ, clearenv(), getenv(), putenv(), setenv(), unsetenv(),

Opis:
Funkcja putenv() dodaje lub zmienia (uaktualnia) wartość zmienej środowiskowej. Argumentem wywołania jest łańcuch znaków w postaci name=value. Jeśli nazwa zmiennej środowiskowej zdefiniowanej w argumencie jako name jeszcze nie istnieje wtedy łańcuch znaków dodawany jest do zmiennych środowiskowych. Jeśli nazwa zmiennej środowiskowej zdefiniowanej w argumencie jako name istnieje wtedy wartość zmiennej środowiskowej jest uaktualniana do wartości zdefiniowanej w argumencie jako value. W przypadku gdy łańcuch znaków nie posiada znaku "=" traktowany jest jako nazwa zmiennej środowiskowej, którą należy usunąć. The string pointed to by string becomes part of the environment, so altering the string changes the environment.

Argumenty:
char *__string - łańcuch znaków w postaci name=value określający w którym "name" określa nazwę dodawanej lub zmienianej (uaktualnianej) zmiennej środowiskowej na wartość "value".

Zwracana wartość:
int - w przypadku poprawnego dodania lub uaktualnienia zmiennej środowiskowej zwracana jest wartość 0, w przeciwym przypadku zwracana jest nie zerowa wartość.

Example:
zawartość pliku putenv.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */



int main(int argc, char **argv) {
	char *self;
	int result;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<2) {
		printf("Usage: %s <envname=envvalue>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s envname=envvalue\n", argv[0]);
		return 0;
	}
	
	result=putenv(argv[1]);
	printf("%s: result=putenv(argv[1]=%s): result=%d\n", self, argv[1], result);
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	printf("%s: execute /bin/bash: system(\"cmd.exe\");\n", self);
	system("cmd.exe");
#else
	printf("%s: execute /bin/bash: system(\"/bin/bash\");\n", self);
	system("/bin/bash");
#endif
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/putenv
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/misc/putenv <envname=envvalue>
Examples:
       /home/local/code/ansiccode/misc/putenv envname=envvalue

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/putenv envname=envvalue
rezultat będzie zależny od podanych argumentów wywołania programu:
putenv: result=putenv(argv[1]=envname=envvalue): result=0
putenv: execute /bin/bash: system("/bin/bash");
należy jeszcze dla zrozumienia działania programu wyświetlić w nowo otwartej powłoce zawartość ustawionej zmiennej środowiskowej (dla niniejszego przykładu envname):
echo "envname=|$envname|"
rezultat będzie zależny od podanego argumentu podczas wywołania programu:
envname=|envvalue|



#top setenv


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji setenv() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji setenv() jest następująca:
/* Set NAME to VALUE in the environment.
   If REPLACE is nonzero, overwrite an existing value.  */
extern int setenv (__const char *__name, __const char *__value, int __replace)
     __THROW __nonnull ((2));

Powiązane:
environ, clearenv(), getenv(), putenv(), setenv(), unsetenv(),

Opis:
Funkcja setenv() dodaje zmienną środowiskową o nazwie przekazanej w argumencie __name o wartości przekazanej w argumencie __value w przypadku gdy zmienna środowiskowa nie istnieje. Jeśli zmienna środowiskowa istnieje to jest ona uaktualniana tylko w przypadku gdy argument __replace jest niezerowy. Jeśli argument __replace jest zerowy wartość istniejącej już zmiennej środowiskowej pozostaje bez zmian.

Argumenty:
const char *__name - nazwa ustawianej lub uaktualnianej zmiennej środowiskowej.
const char *__value - wartość ustawianej lub uaktualnianej zmiennej środowiskowej.
int __replace - argument określający czy istniejąca zmienna może zostać nadpisana (uaktualniona).

Zwracana wartość:
int - w przypadku poprawnego dodania lub uaktualnienia zmiennej środowiskowej zwracana jest wartość 0, w przeciwym przypadku zwracana jest nie zerowa wartość oraz ustawiana globalna zmienna errno.

Example:
zawartość pliku setenv.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */



int main(int argc, char **argv) {
	char *self;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	int result;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<3) {
		printf("Usage:   %s <envname> <envvalue>\n", argv[0]);
		printf("Examples:\n");
		printf("         %s envname envvalue\n", argv[0]);
		return 0;
	}
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* setenv() is not available on this OS platform !!! */
	printf("%s: setenv() is not available on this OS platform !!!\n", argv[0]);
#else
	result=setenv(argv[1], argv[2], 1);
	printf("%s: envval=setenv(argv[1]=%s, argv[2]=%s): result=|%d|\n", self, argv[1], argv[2], result);
	printf("%s: execute /bin/bash: system(\"/bin/bash\");\n", self);
	system("/bin/bash");
#endif
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/setenv
program wyświetli informacje o sposobie uruchamiania programu:
Usage:   /home/local/code/ansiccode/misc/setenv <envname> <envvalue>
Examples:
         /home/local/code/ansiccode/misc/setenv envname envvalue

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/setenv envname envvalue
rezultat będzie zależny od podanych argumentów wywołania programu:
setenv: envval=setenv(argv[1]=envname, argv[2]=envvalue): result=|0|
setenv: execute /bin/bash: system("/bin/bash");
należy jeszcze dla porównania wyświetlić w nowo otwartej powłoce zawartość ustawionej zmiennej środowiskowej (dla niniejszego przykładu envname):
echo "envname=|$envname|"
rezultat będzie zależny od podanego argumentu podczas wywołania programu:
envname=|envvalue|



#top setrlimit


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji setrlimit() znajduje się w pliku nagłówkowym sys/resource.h.
Deklaracja funkcji setrlimit() jest następująca:
/* Set the soft and hard limits for RESOURCE to *RLIMITS.
   Only the super-user can increase hard limits.
   Return 0 if successful, -1 if not (and sets errno).  *:
extern int setrlimit (__rlimit_resource_t __resource,
              __const struct rlimit *__rlimits) __THROW;

Powiązane:
getrlimit(), getrusage(), setrlimit(),

Opis:
Funkcja setrlimit() ustawia limity konsumpcji różnych zasobów systemowych dla danego procesu. Limity zasobów reprezentowane są przez strukturę rlimit. Pole rlim_cur określa "miękki" limit danego zasobu dla procesu, rlim_max określa "twardy" (maksymalny) limit danego zasobu dla procesu.

Limit "miękki" zasobu może zostać zmieniony przez proces do dowolnej wartości mniejszej lub równej wartości "twardego" limitu danego zasobu.
Proces może zmniejszyć wartość "twardego" limitu zasobu do wartości większej lub równej wartości "miękkiego" limitu zasobu.
Tylko proces posiadający odpowiednie przywileje może zwiększać wartości "twardego" limitu danego zasobu.

Argumenty:
__rlimit_resource_t __resource - Określa rodzaj pobieranego limitu dla zasobu. Następujące rodzaje zasobów są zdefiniowane:
RLIMIT_CPU - Maksymalna wartość czasu wykorzystania procesora (w sekundach). Jeśli limit zostanie przekroczony do procesy zostanie wysłany sygnał SIGXCPU. Jeśli proces przechwytuje:ingoruje sygnał SIGXCPU lub jeśli wszystkie wątki procesu blokują sygnał SIGXCPU zachowanie jest nieokreślone.
RLIMIT_FSIZE - Maksymalna wielkość pliku możliwa do utworzenia przez proces (w bajtach). Jeśli operacja zapisu lub przycinania spowoduje przekroczenie limitu, sygnał SIGXFSZ zostanie wygenerowany dla procesu:wątku. Jeśli proces/wątki przechwytują lub blokują sygnał code:ansiccode:misc#SIGXFSZ, kontynuacja prowadząca do zwiększenia rozmiaru pliku powyżej limitu zakończy się błędem oraz zostanie globalna zmienna errno na [EFBIG].
RLIMIT_DATA - Maksymalna wielkość danych dla procesu (w bajtach). Jeśli limit zostanie przekroczony funkcja malloc() zwraca błąd oraz zostaje ustawiona globalna zmienna errno na [ENOMEM].
RLIMIT_STACK - Maksymalny rozmiar stosu dla procesu (w bajtach). Jeśli limit zostanie przekroczony do procesu wysyłany jest sygnał SIGSEGV. Jeśli wątki procesu blokują sygnał SIGSEGV lub proces ignoruje:przechwytuje sygnał SIGSEGV i nie wprowadza zmian prowadzących do używnia alternatywnego stosu, obsługa sygnału SIGSEGV zostanie ustawiona na SIG_DFL zanim sygnał zostanie wygenerowany.
RLIMIT_CORE - Maksymalny rozmiar pliku "zrzutu rdzenia", jaki może zostać utworzony przez proces (w bajtach). Limit ustawiony na 0 zapobiega tworzeniu pliku "zrzutu rdzenia,. Jeśli limit zostanie przekroczony zapis do pliku "zrzutu rdzenia" jest przerywany przy tej wartości.
RLIMIT_RSS - Maksymalny rozmiar pamięci rezydentnej dla procesu. Jeśli limit zostanie przekroczony strony pamięci używane najdawniej będą przenoszone do pamięci swap.
RLIMIT_NOFILE - Maksymalna ilość deskryptorów możliwa do utworzonia przez proces. Jeśli limit zostanie przekroczony próba utworzenia nowego deskryptora zakończy się błędem oraz zostanie ustawiona globalna zmienna errno na [EMFILE].
RLIMIT_AS - Maksymalny rozmiar pamięci dostępnej dla procesu (w bajtach). Jeśli limit zostanie przekroczony funkcja malloc() i mmap() zwrócą błąd oraz zostanie ustawiona globalna zmienna errno na [ENOMEM].
RLIMIT_NPROC - Maksymalna liczba procesów, które użytkownik może uruchomić. Jeśli limit zostanie przekroczony
RLIMIT_MEMLOCK - Maksymalny rozmiar pamięci, która może zostać zablokowana przez funkcja mlock() i mlockall().
RLIMIT_LOCKS - Maksymalna ilość blokać, które proces może utworzyć przez funkcje flock() i fcntl().
RLIMIT_SIGPENDING - Maksymalna ilość sygnałów oczekujących w kolejce do obsłużenia przez proces.
RLIMIT_MSGQUEUE - Maksymalny rozmiar wiadomości w kolejce POSIX.
RLIMIT_NICE - Maksymalny wartość priorytetu dla procesu. Poziomy 19 ... -20 odpowiadają wartościom 0 .. 39 limitu tego zasobu.
RLIMIT_RTPRIO - Maksymalny priorytet realtime dozwolony dla nieuprzywilejowanych procesów.
RLIMIT_NLIMITS - limit
const struct rlimit __rlimits - wskaźnik do struktury rlimit, w której pola rlim_cur oraz rlim_max określają limit "miękki" i "twardy" dla danego zasobu.

Zwracana wartość:
int - w przypadku sukcesu ustawienia limitów zasobów przekazanych w strukturze jako wskaźnik zwracana jest wartość 0 przypadku niepowodzenia zwracana jest wartość -1 oraz ustawiana globalna zmienna errno zawierająca powód występienia błędu.



#top sleep


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji sleep() znajduje się w pliku nagłówkowym unistd.h.
Deklaracja funkcji sleep() jest następująca:
/* Make the process sleep for SECONDS seconds, or until a signal arrives
   and is not ignored.  The function returns the number of seconds less
   than SECONDS which it actually slept (thus zero if it slept the full time).
   If a signal handler does a `longjmp' or modifies the handling of the
   SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
   signal afterwards is undefined.  There is no return value to indicate
   error, but if `sleep' returns SECONDS, it probably didn't work.

   This function is a cancellation point and therefore not marked with
   __THROW.  */
extern unsigned int sleep (unsigned int __seconds);

Powiązane:
nanosleep(), sleep(), usleep(),

Opis:
Funkcja sleep() - powoduje zatrzymanie (uśpienie, opóźnienie) wykonywania bieżącego procesu do upłynięcia zadanego czasu lub odebrania sygnału, który nie jest ingorowany. Czas przerwy może zostać wydłużony przez z powodu dowolnej aktywności systemu lub czasu spędzonego na wywołaniach systemowych.

Argumenty:
unsigned int - czas (w sekundach) na który należy zatrzymać (uśpić, opóźnić) proces.

Zwracana wartość:
unsigned int - w przypadku gdy czas przerwy upłynął zwracana jest wartość 0 lub czas, który jeszcze pozostał jeśli powrót z funkcji nastpąpił wczęśniej (odebrano sygnał, który nie został zignorowany).

Example:
zawartość pliku sleep.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <unistd.h>        /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */
                           /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */
                           /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), fsync(), sync(), [f]truncate(), syscall(), */
#include <errno.h>         /* for errno constant, error constants, */
#include <time.h>          /* for struct timespec, struct tm, time(), difftime(), mktime(), strftime(), strptime(), gmtime(), localtime(), asctime(), ctime(), tzset(), stime(), timegm(), timelocal(), dysize(), nanosleep(), getdate(), */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#else
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), futimes(), futimesat(), */
#endif

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
/* Sleep - Capital first letter */
/* #include <windows.h> + #include <winbase.h> +++ -lws_32 */
#define sleep(time) Sleep(1000*time)
#define usleep(useconds) Sleep((useconds+999) / 1000)
#endif



int main(int argc, char **argv) {
	char *self;
	unsigned int tv_sec;
	unsigned int tv_usec;
	double tv_nsec;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	struct timespec requested_time;
	struct timespec remaining;
#endif
	int result;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<4) {
		printf("Usage: %s <seconds> <microseconds> <nanoseconds>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s 1 2000000 3500000000\n", argv[0]);
		return 0;
	}
	
	tv_sec =atoi(argv[1]);
	tv_usec=atoi(argv[2]);
	tv_nsec=atof(argv[3]);
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* nanosleep() is not available on this OS platform !!! */
	printf("%s: nanosleep() is not available on this OS platform !!!\n", argv[0]);
#else
	memset(&requested_time, 0x00, sizeof(struct timespec));
	memset(&remaining, 0x00, sizeof(struct timespec));
	requested_time.tv_sec=(time_t)((double)tv_nsec/1000000000.0);
	requested_time.tv_nsec=(long int)( (double)tv_nsec - requested_time.tv_sec*1000000000.0);
	
	printf("%s: result=nanosleep(&requested_time={tv_sec=%d, tv_nsec=%ld}, &remaining={tv_sec=%d, tv_nsec=%ld}):\n", self, (int)requested_time.tv_sec, requested_time.tv_nsec, (int)remaining.tv_sec, remaining.tv_nsec);
	result=nanosleep(&requested_time, &remaining);
	if (result>=0) printf("%s: result=nanosleep(&requested_time={tv_sec=%d, tv_nsec=%ld}, &remaining={tv_sec=%d, tv_nsec=%ld}): result=%d if (result>=0): Successful nanosleep()\n", self, (int)requested_time.tv_sec, requested_time.tv_nsec, (int)remaining.tv_sec, remaining.tv_nsec, result);
	else           printf("%s: result=nanosleep(&requested_time={tv_sec=%d, tv_nsec=%ld}, &remaining={tv_sec=%d, tv_nsec=%ld}): result=%d if (result>=0): else: Unable nanosleep(), Reason: %d:%s\n", self, (int)requested_time.tv_sec, requested_time.tv_nsec, (int)remaining.tv_sec, remaining.tv_nsec, result, errno, strerror(errno));
#endif
	
	printf("%s: result=usleep(tv_usec=%d):\n", self, tv_usec);
	result=usleep(tv_usec);
	if (result>=0) printf("%s: result=usleep(tv_usec=%d): result=%d if (result>=0): Successful usleep()\n", self, tv_usec, result);
	else           printf("%s: result=usleep(tv_usec=%d): result=%d if (result>=0): else: Unable usleep(), Reason: %d:%s\n", self, tv_usec, result, errno, strerror(errno));
	
	printf("%s: result=sleep(tv_sec=%d):\n", self, tv_sec);
	result=sleep(tv_sec);
	if (result>=0) printf("%s: result=sleep(tv_sec=%d): result=%d if (result>=0): Successful sleep()\n", self, tv_sec, result);
	else           printf("%s: result=sleep(tv_sec=%d): result=%d if (result>=0): else: Unable to sleep(), Reason: %d:%s\n", self, tv_sec, result, errno, strerror(errno));
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/sleep
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/misc/sleep <seconds> <microseconds> <nanoseconds>
Examples:
       /home/local/code/ansiccode/misc/sleep 1 2000000 3500000000

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/sleep 1 2000000 3500000000
rezultat będzie zależny od podanych argumentów wywołania programu:
sleep: result=nanosleep(&requested_time={tv_sec=3, tv_nsec=500000000}, &remaining={tv_sec=0, tv_nsec=0}):
sleep: result=nanosleep(&requested_time={tv_sec=3, tv_nsec=500000000}, &remaining={tv_sec=0, tv_nsec=0}): result=0 if (result>=0): Successful nanosleep()
sleep: result=usleep(tv_usec=2000000):
sleep: result=usleep(tv_usec=2000000): result=0 if (result>=0): Successful usleep()
sleep: result=sleep(tv_sec=1):
sleep: result=sleep(tv_sec=1): result=0 if (result>=0): Successful sleep()



#top ualarm


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji ualarm() znajduje się w pliku nagłówkowym unistd.h.
Deklaracja funkcji ualarm() jest następująca:
/* Set an alarm to go off (generating a SIGALRM signal) in VALUE
   microseconds.  If INTERVAL is nonzero, when the alarm goes off, the
   timer is reset to go off every INTERVAL microseconds thereafter.
   Returns the number of microseconds remaining before the alarm.  */
extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
     __THROW;

Powiązane:
alarm(), ualarm(),

Opis:
Funkcja ualarm() ustawia czas po którym jądro systemu operacyjnego wygeneruje sygnał SIGALRM dla procesu wywołującego funkcję ualarm(). Jeśli drugi argument wywołania funkcji __interval jest niezerowy sygnał SIGALRM jest wysyłany co każde określone w argumencie __interval mikrosekundy.

Argumenty:
__useconds_t __value - czas (w mikrosekundach) po którym jądro systemu operacyjnego wygeneruje sygnał SIGALRM dla procesu wywołującego funkcję ualarm().
__useconds_t __interval - czas (w mikrosekundach) po każdorazowo których upłynięciu sygnał będzie wysyłany do procesu.

Zwracana wartość:
__useconds_t - ilość mikrosekund po której zostanie wysłany do procesu sygnał SIGALRM lub zero jeśli czas alarmu upłynąc (lub nie ustawiono jeszcze żadnego czasu alarmu)

Example:
zawartość pliku ualarm1.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <unistd.h>        /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */
                           /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(), getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */
                           /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */
#include <signal.h>        /* for SIGHUP, SIGINT, SIGQUIT, SIG_DFL, SIG_ERR, */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <winbase.h>     /* for (struct)FILETIME, (struct)PROCESS_INFORMATION, (struct)SYSTEMTIME, (struct)WIN32_FIND_DATAA, (struct)SYSTEM_INFO, (struct)TIME_ZONE_INFORMATION, */
                           /* for OpenFile(), CreateFile(), CreateDirectory(), ReadFile(), WriteFile(), CloseHandle(), */
                           /* for CompareFileTime(), DosDateTimeToFileTime(), FileTimeToLocalFileTime(), GetFileTime(), LocalFileTimeToFileTime(), SetFileTime(), SystemTimeToFileTime(), */
#endif

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
/* Sleep - Capital first letter */
/* #include <windows.h> + #include <winbase.h> +++ -lws2_32 */
#define sleep(time) Sleep(1000*time)
#define usleep(useconds) Sleep((useconds+999) / 1000)
#endif



void ALARMhandler(int sig) {
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	int result;
#endif
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* signal() is not available on this OS platform !!! */
#else
	signal(SIGALRM, ALARMhandler);     /* reinstall the handler */
#endif
	printf("ALARMhandler(int sig=%d): Hello\n", sig);
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* ualarm() is not available on this OS platform !!! */
#else
	/*result=ualarm(100000, 0);*/
	/*printf("ALARMhandler(int sig=%d): result=ualarm(100000, 0): result=%d\n", sig, result);*/
#endif
}



int main(int argc, char **argv) {
	char *self;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	int result;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", argv[0]);
		return 0;
	}
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* SIGALRM is not available on this OS platform !!! */
	printf("%s: SIGALRM is not available on this OS platform !!!\n", argv[0]);
	
	/* signal() is not available on this OS platform !!! */
	printf("%s: signal() is not available on this OS platform !!!\n", argv[0]);
	
	/* ualarm() is not available on this OS platform !!! */
	printf("%s: ualarm() is not available on this OS platform !!!\n", argv[0]);
#else
	signal(SIGALRM, ALARMhandler);
	result=ualarm(100000, 100000);
	printf("%s: result=ualarm(100000, 100000): result=%d\n", self, result);
#endif
	
	while (1) sleep(1);
	printf("All done\n");
	
	return 0;
}


program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/ualarm1
program wyświetli stosowne informacje o sposobie działania (ze względu na nieskończoną pętlę znajdującą się w programie działanie programu należy przerwać, zakońcyć kombinacją klawiszyCTRL+C):
ualarm1: result=ualarm(100000, 100000): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): Hello

Example:
zawartość pliku ualarm2.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <unistd.h>        /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */
                           /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(), getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */
                           /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */
#include <signal.h>        /* for SIGHUP, SIGINT, SIGQUIT, SIG_DFL, SIG_ERR, */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <winbase.h>     /* for (struct)FILETIME, (struct)PROCESS_INFORMATION, (struct)SYSTEMTIME, (struct)WIN32_FIND_DATAA, (struct)SYSTEM_INFO, (struct)TIME_ZONE_INFORMATION, */
                           /* for OpenFile(), CreateFile(), CreateDirectory(), ReadFile(), WriteFile(), CloseHandle(), */
                           /* for CompareFileTime(), DosDateTimeToFileTime(), FileTimeToLocalFileTime(), GetFileTime(), LocalFileTimeToFileTime(), SetFileTime(), SystemTimeToFileTime(), */
#endif

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
/* Sleep - Capital first letter */
/* #include <windows.h> + #include <winbase.h> +++ -lws2_32 */
#define sleep(time) Sleep(1000*time)
#define usleep(useconds) Sleep((useconds+999) / 1000)
#endif



void ALARMhandler(int sig) {
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	int result;
#endif
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* signal() is not available on this OS platform !!! */
#else
	signal(SIGALRM, ALARMhandler);     /* reinstall the handler */
#endif
	printf("ALARMhandler(int sig=%d): Hello\n", sig);
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* ualarm() is not available on this OS platform !!! */
#else
	result=ualarm(100000, 0);
	printf("ALARMhandler(int sig=%d): result=ualarm(100000, 0): result=%d\n", sig, result);
#endif
}



int main(int argc, char **argv) {
	char *self;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
	int result;
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<1) {
		printf("Usage: %s\n", argv[0]);
		return 0;
	}
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* SIGALRM is not available on this OS platform !!! */
	printf("%s: SIGALRM is not available on this OS platform !!!\n", argv[0]);
	
	/* signal() is not available on this OS platform !!! */
	printf("%s: signal() is not available on this OS platform !!!\n", argv[0]);
	
	/* ualarm() is not available on this OS platform !!! */
	printf("%s: ualarm() is not available on this OS platform !!!\n", argv[0]);
#else
	signal(SIGALRM, ALARMhandler);
	result=ualarm(100000, 0);
	printf("%s: result=ualarm(100000, 0): result=%d\n", self, result);
#endif
	
	while (1) sleep(1);
	printf("All done\n");
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/ualarm2
program wyświetli stosowne informacje o sposobie działania (ze względu na nieskończoną pętlę znajdującą się w programie działanie programu należy przerwać, zakońcyć kombinacją klawiszyCTRL+C):
ualarm2: result=ualarm(100000, 0): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=ualarm(100000, 0): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=ualarm(100000, 0): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=ualarm(100000, 0): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=ualarm(100000, 0): result=0
ALARMhandler(int sig=14): Hello
ALARMhandler(int sig=14): result=ualarm(100000, 0): result=0



#top unsetenv


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji unsetenv() znajduje się w pliku nagłówkowym stdlib.h.
Deklaracja funkcji unsetenv() jest następująca:
/* Remove the variable NAME from the environment.  */
extern int unsetenv (__const char *__name) __THROW;

Powiązane:
environ, clearenv(), getenv(), putenv(), setenv(), unsetenv(),

Opis:
Funkcja unsetenv() usuwa zmienną środowiskową o nazwie podanym w argumencie wywołania __name.

Argumenty:
const char *__name - nazwa zmiennej środowiskowej, która ma zostać usunięta.

Zwracana wartość:
int - w przypadku poprawnego usunięcia zmiennej środowiskowej zwracana jest wartość 0, w przeciwym przypadku zwracana jest nie zerowa wartość oraz ustawiana globalna zmienna errno.

Example:
zawartość pliku unsetenv.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <errno.h>         /* for errno constant, error constants, */



int main(int argc, char **argv) {
	char *self;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
#else
#if defined(HAVE_UNSETENV_RESULT)
	int result;
#endif
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<2) {
		printf("Usage:   %s <envname>\n", argv[0]);
		printf("Examples:\n");
		printf("         %s envname\n", argv[0]);
		return 0;
	}
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* unsetenv() is not available on this OS platform !!! */
	printf("%s: unsetenv() is not available on this OS platform !!!\n", argv[0]);
#else
	
#if defined(HAVE_UNSETENV_RESULT)
	result=unsetenv(argv[1]);
	if (result==0) printf("%s: result=unsetenv(argv[1]=%s): result=%d if (result>=0): Successful clearenv().\n", self, argv[1], result);
	else           printf("%s: result=unsetenv(argv[1]=%s): result=%d if (result>=0): else: Unable to clearenv(), Reason: %d:%s\n", self, argv[1], result, errno, strerror(errno));
#else
	unsetenv(argv[1]);
#endif
	
	printf("%s: execute /bin/bash: system(\"/bin/bash\");\n", self);
	system("/bin/bash");
#endif
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/misc/unsetenv
program wyświetli informacje o sposobie uruchamiania programu:
Usage:   /home/local/code/ansiccode/misc/unsetenv <envname>
Examples:
         /home/local/code/ansiccode/misc/unsetenv envname

przed wywołaniem programu należy w powłoce wyświetlić zawartość zmiennej środowiskowej podanej jako argument wywołania programu (dla niniejszego przykładu USER):
echo $USER
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/misc/unsetenv USER
rezultat będzie zależny od podanych argumentów wywołania programu:
unsetenv: result=unsetenv(argv[1]=USER): result=0 if (result>=0): Successful clearenv().
unsetenv: execute /bin/bash: system("/bin/bash");
należy jeszcze dla porównania wyświetlić w nowo otwartej powłoce zawartość zmiennej środowiskowej i porównać z wcześniej otrzymaną wartością (dla niniejszego przykładu USER):
echo $USER



#top usleep


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji usleep() znajduje się w pliku nagłówkowym unistd.h.
Deklaracja funkcji usleep() jest następująca:
/* Sleep USECONDS microseconds, or until a signal arrives that is not blocked
   or ignored.

   This function is a cancellation point and therefore not marked with
   __THROW.  */
extern int usleep (__useconds_t __useconds);

Powiązane:
nanosleep(), sleep(), usleep(),

Opis:
Funkcja usleep() - powoduje zatrzymanie (uśpienie, opóźnienie) wykonywania bieżącego procesu do upłynięcia zadanego czasu. Czas przerwy może zostać wydłużony przez z pwowodu dowolnej aktywności systemu lub czasu spędzonego na wywołaniach systemowych.

Argumenty:
__useconds_t __useconds - czas (w mikrosekundach) na który należy zatrzymać (uśpić, opóźnić) proces.

Zwracana wartość:
int - w przypadku gdy czas przerwy upłynął zwracana jest wartość 0 lub wartość -1 w przypadku wystąpienia błędu globalna zmienna errno zawierająca kod błędu.





Zmodyfikowany ostatnio: 2015/04/29 10:15:53 (9 lat temu), textsize: 236 kB, htmlsize: 337 kB

Zapraszam do komentowania, zgłaszania sugestii, propozycji, własnych przykładów, ...
Dodaj komentarzKomentarze użytkowników