- ANSI C
- » Variable handling
- » Miscellaneous
- » POSIX
- » Date/Time
- » Math
- » menu_code_ansiccode_strings
- » PCRE
- » Arrays
- » Classes
- » Program execute
- » Directories
- » Filesystem
- » Memory
- » GD
- » Network
- » Sockets
- PERL
- PHP
- JavaScript
CONTENT
- CHANGES
Szukaj
#top Program execution¶
- Program execution
- Makefile
- Makefile (linux)
- Makefile.obsd
- Makefile.fbsd
- Makefile.sol
- Makefile.beos
- Makefile.win
- Predefined Constants
- WAIT_ANY
- WAIT_MYPGRP
- WNOHANG
- WUNTRACED
- P_***
- Datatypes / MACROS
- __clock_t
- __id_t
- __off_t
- __pid_t
- __priority_which_t
- __suseconds_t
- __time_t
- __uid_t
- __WAIT_STATUS
- _G_off_t
- _IO_lock_t
- _IO_off_t
- FILE
- id_t
- idtype_t
- pid_t
- siginfo_t
- sigval_t
- struct _IO_FILE
- struct _IO_marker
- struct rusage
- struct timeval
- union wait
- Program execution Functions
- execl
- execle
- execlp
- execv
- execve
- execvp
- fork
- getpriority
- nice
- pclose
- pipe
- popen
- setpriority
- system
- wait
- wait3
- wait4
- waitid
- waitpid
code / ansic / execute
#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 z wywoływaniem programów.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: $(EXECL) ...
, 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 execl
należy zakomentować ostatnią pozycję rozpoczynającą się od make: $(EXECL) ...
(wstawić na początku przed make znak #
), a następnie odkomentować pozycję: #make: $(EXECL)
(usunąć znak #
).#top Makefile (linux)¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = -DHAVE_NICE=1 -DHAVE_GETPRIORITY=1 -DHAVE_SETPRIORITY=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 EXECL = execl EXECLE = execle EXECLP = execlp EXECV = execv EXECVE = execve EXECVP = execvp FORK = fork GETPRIORITY = getpriority NICE = nice PCLOSE = pclose PIPE = pipe POPEN = popen SETPRIORITY = setpriority SYSTEM = system all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(EXECL) #make: $(EXECLE) #make: $(EXECLP) #make: $(EXECV) #make: $(EXECVE) #make: $(EXECVP) #make: $(FORK) #make: $(GETPRIORITY) #make: $(NICE) #make: $(PAUSE) #make: $(PCLOSE) #make: $(PIPE) #make: $(POPEN) #make: $(SETPRIORITY) #make: $(SYSTEM) make: $(EXECL) $(EXECLE) $(EXECLP) $(EXECV) $(EXECVE) $(EXECVP) $(FORK) $(GETPRIORITY) $(NICE) $(PAUSE) $(PCLOSE) $(PIPE) $(POPEN) $(SETPRIORITY) $(SYSTEM) $(EXECL): $(EXECL).o $(GCC) -o $(EXECL) obj/$(EXECL).o $(LDFLAGS) $(EXECL).o: $(GCC) -o obj/$(EXECL).o -c $(EXECL).c $(CFLAGS) $(EXECLE): $(EXECLE).o $(GCC) -o $(EXECLE) obj/$(EXECLE).o $(LDFLAGS) $(EXECLE).o: $(GCC) -o obj/$(EXECLE).o -c $(EXECLE).c $(CFLAGS) $(EXECLP): $(EXECLP).o $(GCC) -o $(EXECLP) obj/$(EXECLP).o $(LDFLAGS) $(EXECLP).o: $(GCC) -o obj/$(EXECLP).o -c $(EXECLP).c $(CFLAGS) $(EXECV): $(EXECV).o $(GCC) -o $(EXECV) obj/$(EXECV).o $(LDFLAGS) $(EXECV).o: $(GCC) -o obj/$(EXECV).o -c $(EXECV).c $(CFLAGS) $(EXECVE): $(EXECVE).o $(GCC) -o $(EXECVE) obj/$(EXECVE).o $(LDFLAGS) $(EXECVE).o: $(GCC) -o obj/$(EXECVE).o -c $(EXECVE).c $(CFLAGS) $(EXECVP): $(EXECVP).o $(GCC) -o $(EXECVP) obj/$(EXECVP).o $(LDFLAGS) $(EXECVP).o: $(GCC) -o obj/$(EXECVP).o -c $(EXECVP).c $(CFLAGS) $(FORK): $(FORK).o $(GCC) -o $(FORK) obj/$(FORK).o $(LDFLAGS) $(FORK).o: $(GCC) -o obj/$(FORK).o -c $(FORK).c $(CFLAGS) $(GETPRIORITY): $(GETPRIORITY).o $(GCC) -o $(GETPRIORITY) obj/$(GETPRIORITY).o $(LDFLAGS) $(GETPRIORITY).o: $(GCC) -o obj/$(GETPRIORITY).o -c $(GETPRIORITY).c $(CFLAGS) $(NICE): $(NICE).o $(GCC) -o $(NICE) obj/$(NICE).o $(LDFLAGS) $(NICE).o: $(GCC) -o obj/$(NICE).o -c $(NICE).c $(CFLAGS) $(PAUSE): $(PAUSE).o $(GCC) -o $(PAUSE) obj/$(PAUSE).o $(LDFLAGS) $(PAUSE).o: $(GCC) -o obj/$(PAUSE).o -c $(PAUSE).c $(CFLAGS) $(PCLOSE): $(PCLOSE).o $(GCC) -o $(PCLOSE) obj/$(PCLOSE).o $(LDFLAGS) $(PCLOSE).o: $(GCC) -o obj/$(PCLOSE).o -c $(PCLOSE).c $(CFLAGS) $(PIPE): $(PIPE).o $(GCC) -o $(PIPE) obj/$(PIPE).o $(LDFLAGS) $(PIPE).o: $(GCC) -o obj/$(PIPE).o -c $(PIPE).c $(CFLAGS) $(POPEN): $(POPEN).o $(GCC) -o $(POPEN) obj/$(POPEN).o $(LDFLAGS) $(POPEN).o: $(GCC) -o obj/$(POPEN).o -c $(POPEN).c $(CFLAGS) $(SETPRIORITY): $(SETPRIORITY).o $(GCC) -o $(SETPRIORITY) obj/$(SETPRIORITY).o $(LDFLAGS) $(SETPRIORITY).o: $(GCC) -o obj/$(SETPRIORITY).o -c $(SETPRIORITY).c $(CFLAGS) $(SYSTEM): $(SYSTEM).o $(GCC) -o $(SYSTEM) obj/$(SYSTEM).o $(LDFLAGS) $(SYSTEM).o: $(GCC) -o obj/$(SYSTEM).o -c $(SYSTEM).c $(CFLAGS)
#top Makefile.obsd¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = -DHAVE_NICE=1 -DHAVE_GETPRIORITY=1 -DHAVE_SETPRIORITY=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 EXECL = execl EXECLE = execle EXECLP = execlp EXECV = execv EXECVE = execve EXECVP = execvp FORK = fork GETPRIORITY = getpriority NICE = nice PCLOSE = pclose PIPE = pipe POPEN = popen SETPRIORITY = setpriority SYSTEM = system all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(EXECL) #make: $(EXECLE) #make: $(EXECLP) #make: $(EXECV) #make: $(EXECVE) #make: $(EXECVP) #make: $(FORK) #make: $(GETPRIORITY) #make: $(NICE) #make: $(PAUSE) #make: $(PCLOSE) #make: $(PIPE) #make: $(POPEN) #make: $(SETPRIORITY) #make: $(SYSTEM) make: $(EXECL) $(EXECLE) $(EXECLP) $(EXECV) $(EXECVE) $(EXECVP) $(FORK) $(GETPRIORITY) $(NICE) $(PAUSE) $(PCLOSE) $(PIPE) $(POPEN) $(SETPRIORITY) $(SYSTEM) $(EXECL): $(EXECL).o $(GCC) -o $(EXECL) obj/$(EXECL).o $(LDFLAGS) $(EXECL).o: $(GCC) -o obj/$(EXECL).o -c $(EXECL).c $(CFLAGS) $(EXECLE): $(EXECLE).o $(GCC) -o $(EXECLE) obj/$(EXECLE).o $(LDFLAGS) $(EXECLE).o: $(GCC) -o obj/$(EXECLE).o -c $(EXECLE).c $(CFLAGS) $(EXECLP): $(EXECLP).o $(GCC) -o $(EXECLP) obj/$(EXECLP).o $(LDFLAGS) $(EXECLP).o: $(GCC) -o obj/$(EXECLP).o -c $(EXECLP).c $(CFLAGS) $(EXECV): $(EXECV).o $(GCC) -o $(EXECV) obj/$(EXECV).o $(LDFLAGS) $(EXECV).o: $(GCC) -o obj/$(EXECV).o -c $(EXECV).c $(CFLAGS) $(EXECVE): $(EXECVE).o $(GCC) -o $(EXECVE) obj/$(EXECVE).o $(LDFLAGS) $(EXECVE).o: $(GCC) -o obj/$(EXECVE).o -c $(EXECVE).c $(CFLAGS) $(EXECVP): $(EXECVP).o $(GCC) -o $(EXECVP) obj/$(EXECVP).o $(LDFLAGS) $(EXECVP).o: $(GCC) -o obj/$(EXECVP).o -c $(EXECVP).c $(CFLAGS) $(FORK): $(FORK).o $(GCC) -o $(FORK) obj/$(FORK).o $(LDFLAGS) $(FORK).o: $(GCC) -o obj/$(FORK).o -c $(FORK).c $(CFLAGS) $(GETPRIORITY): $(GETPRIORITY).o $(GCC) -o $(GETPRIORITY) obj/$(GETPRIORITY).o $(LDFLAGS) $(GETPRIORITY).o: $(GCC) -o obj/$(GETPRIORITY).o -c $(GETPRIORITY).c $(CFLAGS) $(NICE): $(NICE).o $(GCC) -o $(NICE) obj/$(NICE).o $(LDFLAGS) $(NICE).o: $(GCC) -o obj/$(NICE).o -c $(NICE).c $(CFLAGS) $(PAUSE): $(PAUSE).o $(GCC) -o $(PAUSE) obj/$(PAUSE).o $(LDFLAGS) $(PAUSE).o: $(GCC) -o obj/$(PAUSE).o -c $(PAUSE).c $(CFLAGS) $(PCLOSE): $(PCLOSE).o $(GCC) -o $(PCLOSE) obj/$(PCLOSE).o $(LDFLAGS) $(PCLOSE).o: $(GCC) -o obj/$(PCLOSE).o -c $(PCLOSE).c $(CFLAGS) $(PIPE): $(PIPE).o $(GCC) -o $(PIPE) obj/$(PIPE).o $(LDFLAGS) $(PIPE).o: $(GCC) -o obj/$(PIPE).o -c $(PIPE).c $(CFLAGS) $(POPEN): $(POPEN).o $(GCC) -o $(POPEN) obj/$(POPEN).o $(LDFLAGS) $(POPEN).o: $(GCC) -o obj/$(POPEN).o -c $(POPEN).c $(CFLAGS) $(SETPRIORITY): $(SETPRIORITY).o $(GCC) -o $(SETPRIORITY) obj/$(SETPRIORITY).o $(LDFLAGS) $(SETPRIORITY).o: $(GCC) -o obj/$(SETPRIORITY).o -c $(SETPRIORITY).c $(CFLAGS) $(SYSTEM): $(SYSTEM).o $(GCC) -o $(SYSTEM) obj/$(SYSTEM).o $(LDFLAGS) $(SYSTEM).o: $(GCC) -o obj/$(SYSTEM).o -c $(SYSTEM).c $(CFLAGS)
#top Makefile.fbsd¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = -DHAVE_NICE=1 -DHAVE_GETPRIORITY=1 -DHAVE_SETPRIORITY=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 EXECL = execl EXECLE = execle EXECLP = execlp EXECV = execv EXECVE = execve EXECVP = execvp FORK = fork GETPRIORITY = getpriority NICE = nice PCLOSE = pclose PIPE = pipe POPEN = popen SETPRIORITY = setpriority SYSTEM = system all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(EXECL) #make: $(EXECLE) #make: $(EXECLP) #make: $(EXECV) #make: $(EXECVE) #make: $(EXECVP) #make: $(FORK) #make: $(GETPRIORITY) #make: $(NICE) #make: $(PAUSE) #make: $(PCLOSE) #make: $(PIPE) #make: $(POPEN) #make: $(SETPRIORITY) #make: $(SYSTEM) make: $(EXECL) $(EXECLE) $(EXECLP) $(EXECV) $(EXECVE) $(EXECVP) $(FORK) $(GETPRIORITY) $(NICE) $(PAUSE) $(PCLOSE) $(PIPE) $(POPEN) $(SETPRIORITY) $(SYSTEM) $(EXECL): $(EXECL).o $(GCC) -o $(EXECL) obj/$(EXECL).o $(LDFLAGS) $(EXECL).o: $(GCC) -o obj/$(EXECL).o -c $(EXECL).c $(CFLAGS) $(EXECLE): $(EXECLE).o $(GCC) -o $(EXECLE) obj/$(EXECLE).o $(LDFLAGS) $(EXECLE).o: $(GCC) -o obj/$(EXECLE).o -c $(EXECLE).c $(CFLAGS) $(EXECLP): $(EXECLP).o $(GCC) -o $(EXECLP) obj/$(EXECLP).o $(LDFLAGS) $(EXECLP).o: $(GCC) -o obj/$(EXECLP).o -c $(EXECLP).c $(CFLAGS) $(EXECV): $(EXECV).o $(GCC) -o $(EXECV) obj/$(EXECV).o $(LDFLAGS) $(EXECV).o: $(GCC) -o obj/$(EXECV).o -c $(EXECV).c $(CFLAGS) $(EXECVE): $(EXECVE).o $(GCC) -o $(EXECVE) obj/$(EXECVE).o $(LDFLAGS) $(EXECVE).o: $(GCC) -o obj/$(EXECVE).o -c $(EXECVE).c $(CFLAGS) $(EXECVP): $(EXECVP).o $(GCC) -o $(EXECVP) obj/$(EXECVP).o $(LDFLAGS) $(EXECVP).o: $(GCC) -o obj/$(EXECVP).o -c $(EXECVP).c $(CFLAGS) $(FORK): $(FORK).o $(GCC) -o $(FORK) obj/$(FORK).o $(LDFLAGS) $(FORK).o: $(GCC) -o obj/$(FORK).o -c $(FORK).c $(CFLAGS) $(GETPRIORITY): $(GETPRIORITY).o $(GCC) -o $(GETPRIORITY) obj/$(GETPRIORITY).o $(LDFLAGS) $(GETPRIORITY).o: $(GCC) -o obj/$(GETPRIORITY).o -c $(GETPRIORITY).c $(CFLAGS) $(NICE): $(NICE).o $(GCC) -o $(NICE) obj/$(NICE).o $(LDFLAGS) $(NICE).o: $(GCC) -o obj/$(NICE).o -c $(NICE).c $(CFLAGS) $(PAUSE): $(PAUSE).o $(GCC) -o $(PAUSE) obj/$(PAUSE).o $(LDFLAGS) $(PAUSE).o: $(GCC) -o obj/$(PAUSE).o -c $(PAUSE).c $(CFLAGS) $(PCLOSE): $(PCLOSE).o $(GCC) -o $(PCLOSE) obj/$(PCLOSE).o $(LDFLAGS) $(PCLOSE).o: $(GCC) -o obj/$(PCLOSE).o -c $(PCLOSE).c $(CFLAGS) $(PIPE): $(PIPE).o $(GCC) -o $(PIPE) obj/$(PIPE).o $(LDFLAGS) $(PIPE).o: $(GCC) -o obj/$(PIPE).o -c $(PIPE).c $(CFLAGS) $(POPEN): $(POPEN).o $(GCC) -o $(POPEN) obj/$(POPEN).o $(LDFLAGS) $(POPEN).o: $(GCC) -o obj/$(POPEN).o -c $(POPEN).c $(CFLAGS) $(SETPRIORITY): $(SETPRIORITY).o $(GCC) -o $(SETPRIORITY) obj/$(SETPRIORITY).o $(LDFLAGS) $(SETPRIORITY).o: $(GCC) -o obj/$(SETPRIORITY).o -c $(SETPRIORITY).c $(CFLAGS) $(SYSTEM): $(SYSTEM).o $(GCC) -o $(SYSTEM) obj/$(SYSTEM).o $(LDFLAGS) $(SYSTEM).o: $(GCC) -o obj/$(SYSTEM).o -c $(SYSTEM).c $(CFLAGS)
#top Makefile.sol¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = -DHAVE_NICE=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 EXECL = execl EXECLE = execle EXECLP = execlp EXECV = execv EXECVE = execve EXECVP = execvp FORK = fork GETPRIORITY = getpriority NICE = nice PCLOSE = pclose PIPE = pipe POPEN = popen SETPRIORITY = setpriority SYSTEM = system all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(EXECL) #make: $(EXECLE) #make: $(EXECLP) #make: $(EXECV) #make: $(EXECVE) #make: $(EXECVP) #make: $(FORK) #make: $(GETPRIORITY) #make: $(NICE) #make: $(PAUSE) #make: $(PCLOSE) #make: $(PIPE) #make: $(POPEN) #make: $(SETPRIORITY) #make: $(SYSTEM) make: $(EXECL) $(EXECLE) $(EXECLP) $(EXECV) $(EXECVE) $(EXECVP) $(FORK) $(GETPRIORITY) $(NICE) $(PAUSE) $(PCLOSE) $(PIPE) $(POPEN) $(SETPRIORITY) $(SYSTEM) $(EXECL): $(EXECL).o $(GCC) -o $(EXECL) obj/$(EXECL).o $(LDFLAGS) $(EXECL).o: $(GCC) -o obj/$(EXECL).o -c $(EXECL).c $(CFLAGS) $(EXECLE): $(EXECLE).o $(GCC) -o $(EXECLE) obj/$(EXECLE).o $(LDFLAGS) $(EXECLE).o: $(GCC) -o obj/$(EXECLE).o -c $(EXECLE).c $(CFLAGS) $(EXECLP): $(EXECLP).o $(GCC) -o $(EXECLP) obj/$(EXECLP).o $(LDFLAGS) $(EXECLP).o: $(GCC) -o obj/$(EXECLP).o -c $(EXECLP).c $(CFLAGS) $(EXECV): $(EXECV).o $(GCC) -o $(EXECV) obj/$(EXECV).o $(LDFLAGS) $(EXECV).o: $(GCC) -o obj/$(EXECV).o -c $(EXECV).c $(CFLAGS) $(EXECVE): $(EXECVE).o $(GCC) -o $(EXECVE) obj/$(EXECVE).o $(LDFLAGS) $(EXECVE).o: $(GCC) -o obj/$(EXECVE).o -c $(EXECVE).c $(CFLAGS) $(EXECVP): $(EXECVP).o $(GCC) -o $(EXECVP) obj/$(EXECVP).o $(LDFLAGS) $(EXECVP).o: $(GCC) -o obj/$(EXECVP).o -c $(EXECVP).c $(CFLAGS) $(FORK): $(FORK).o $(GCC) -o $(FORK) obj/$(FORK).o $(LDFLAGS) $(FORK).o: $(GCC) -o obj/$(FORK).o -c $(FORK).c $(CFLAGS) $(GETPRIORITY): $(GETPRIORITY).o $(GCC) -o $(GETPRIORITY) obj/$(GETPRIORITY).o $(LDFLAGS) $(GETPRIORITY).o: $(GCC) -o obj/$(GETPRIORITY).o -c $(GETPRIORITY).c $(CFLAGS) $(NICE): $(NICE).o $(GCC) -o $(NICE) obj/$(NICE).o $(LDFLAGS) $(NICE).o: $(GCC) -o obj/$(NICE).o -c $(NICE).c $(CFLAGS) $(PAUSE): $(PAUSE).o $(GCC) -o $(PAUSE) obj/$(PAUSE).o $(LDFLAGS) $(PAUSE).o: $(GCC) -o obj/$(PAUSE).o -c $(PAUSE).c $(CFLAGS) $(PCLOSE): $(PCLOSE).o $(GCC) -o $(PCLOSE) obj/$(PCLOSE).o $(LDFLAGS) $(PCLOSE).o: $(GCC) -o obj/$(PCLOSE).o -c $(PCLOSE).c $(CFLAGS) $(PIPE): $(PIPE).o $(GCC) -o $(PIPE) obj/$(PIPE).o $(LDFLAGS) $(PIPE).o: $(GCC) -o obj/$(PIPE).o -c $(PIPE).c $(CFLAGS) $(POPEN): $(POPEN).o $(GCC) -o $(POPEN) obj/$(POPEN).o $(LDFLAGS) $(POPEN).o: $(GCC) -o obj/$(POPEN).o -c $(POPEN).c $(CFLAGS) $(SETPRIORITY): $(SETPRIORITY).o $(GCC) -o $(SETPRIORITY) obj/$(SETPRIORITY).o $(LDFLAGS) $(SETPRIORITY).o: $(GCC) -o obj/$(SETPRIORITY).o -c $(SETPRIORITY).c $(CFLAGS) $(SYSTEM): $(SYSTEM).o $(GCC) -o $(SYSTEM) obj/$(SYSTEM).o $(LDFLAGS) $(SYSTEM).o: $(GCC) -o obj/$(SYSTEM).o -c $(SYSTEM).c $(CFLAGS)
#top Makefile.beos¶
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 LIBS = LIBDIRS = LDFLAGS = $(LIBDIRS) $(LIBS) RM = rm -f MKDCMD = mkdir -p EXECL = execl EXECLE = execle EXECLP = execlp EXECV = execv EXECVE = execve EXECVP = execvp FORK = fork GETPRIORITY = getpriority NICE = nice PCLOSE = pclose PIPE = pipe POPEN = popen SETPRIORITY = setpriority SYSTEM = system all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(EXECL) #make: $(EXECLE) #make: $(EXECLP) #make: $(EXECV) #make: $(EXECVE) #make: $(EXECVP) #make: $(FORK) #make: $(GETPRIORITY) #make: $(NICE) #make: $(PAUSE) #make: $(PCLOSE) #make: $(PIPE) #make: $(POPEN) #make: $(SETPRIORITY) #make: $(SYSTEM) make: $(EXECL) $(EXECLE) $(EXECLP) $(EXECV) $(EXECVE) $(EXECVP) $(FORK) $(GETPRIORITY) $(NICE) $(PAUSE) $(PCLOSE) $(PIPE) $(POPEN) $(SETPRIORITY) $(SYSTEM) $(EXECL): $(EXECL).o $(GCC) -o $(EXECL) obj/$(EXECL).o $(LDFLAGS) $(EXECL).o: $(GCC) -o obj/$(EXECL).o -c $(EXECL).c $(CFLAGS) $(EXECLE): $(EXECLE).o $(GCC) -o $(EXECLE) obj/$(EXECLE).o $(LDFLAGS) $(EXECLE).o: $(GCC) -o obj/$(EXECLE).o -c $(EXECLE).c $(CFLAGS) $(EXECLP): $(EXECLP).o $(GCC) -o $(EXECLP) obj/$(EXECLP).o $(LDFLAGS) $(EXECLP).o: $(GCC) -o obj/$(EXECLP).o -c $(EXECLP).c $(CFLAGS) $(EXECV): $(EXECV).o $(GCC) -o $(EXECV) obj/$(EXECV).o $(LDFLAGS) $(EXECV).o: $(GCC) -o obj/$(EXECV).o -c $(EXECV).c $(CFLAGS) $(EXECVE): $(EXECVE).o $(GCC) -o $(EXECVE) obj/$(EXECVE).o $(LDFLAGS) $(EXECVE).o: $(GCC) -o obj/$(EXECVE).o -c $(EXECVE).c $(CFLAGS) $(EXECVP): $(EXECVP).o $(GCC) -o $(EXECVP) obj/$(EXECVP).o $(LDFLAGS) $(EXECVP).o: $(GCC) -o obj/$(EXECVP).o -c $(EXECVP).c $(CFLAGS) $(FORK): $(FORK).o $(GCC) -o $(FORK) obj/$(FORK).o $(LDFLAGS) $(FORK).o: $(GCC) -o obj/$(FORK).o -c $(FORK).c $(CFLAGS) $(GETPRIORITY): $(GETPRIORITY).o $(GCC) -o $(GETPRIORITY) obj/$(GETPRIORITY).o $(LDFLAGS) $(GETPRIORITY).o: $(GCC) -o obj/$(GETPRIORITY).o -c $(GETPRIORITY).c $(CFLAGS) $(NICE): $(NICE).o $(GCC) -o $(NICE) obj/$(NICE).o $(LDFLAGS) $(NICE).o: $(GCC) -o obj/$(NICE).o -c $(NICE).c $(CFLAGS) $(PAUSE): $(PAUSE).o $(GCC) -o $(PAUSE) obj/$(PAUSE).o $(LDFLAGS) $(PAUSE).o: $(GCC) -o obj/$(PAUSE).o -c $(PAUSE).c $(CFLAGS) $(PCLOSE): $(PCLOSE).o $(GCC) -o $(PCLOSE) obj/$(PCLOSE).o $(LDFLAGS) $(PCLOSE).o: $(GCC) -o obj/$(PCLOSE).o -c $(PCLOSE).c $(CFLAGS) $(PIPE): $(PIPE).o $(GCC) -o $(PIPE) obj/$(PIPE).o $(LDFLAGS) $(PIPE).o: $(GCC) -o obj/$(PIPE).o -c $(PIPE).c $(CFLAGS) $(POPEN): $(POPEN).o $(GCC) -o $(POPEN) obj/$(POPEN).o $(LDFLAGS) $(POPEN).o: $(GCC) -o obj/$(POPEN).o -c $(POPEN).c $(CFLAGS) $(SETPRIORITY): $(SETPRIORITY).o $(GCC) -o $(SETPRIORITY) obj/$(SETPRIORITY).o $(LDFLAGS) $(SETPRIORITY).o: $(GCC) -o obj/$(SETPRIORITY).o -c $(SETPRIORITY).c $(CFLAGS) $(SYSTEM): $(SYSTEM).o $(GCC) -o $(SYSTEM) obj/$(SYSTEM).o $(LDFLAGS) $(SYSTEM).o: $(GCC) -o obj/$(SYSTEM).o -c $(SYSTEM).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 = -lws2_32 LIBDIRS = LDFLAGS = $(LIBDIRS) $(LIBS) RM = del /q /s MKDCMD = mkdir EXECL = execl EXECLE = execle EXECLP = execlp EXECV = execv EXECVE = execve EXECVP = execvp FORK = fork GETPRIORITY = getpriority NICE = nice PCLOSE = pclose PIPE = pipe POPEN = popen SETPRIORITY = setpriority SYSTEM = system all: make objdir: $(MKDCMD) obj\ clean: $(RM) obj\*.o *.o *~ #make: $(EXECL) #make: $(EXECLE) #make: $(EXECLP) #make: $(EXECV) #make: $(EXECVE) #make: $(EXECVP) #make: $(FORK) #make: $(GETPRIORITY) #make: $(NICE) #make: $(PAUSE) #make: $(PCLOSE) #make: $(PIPE) #make: $(POPEN) #make: $(SETPRIORITY) #make: $(SYSTEM) make: $(EXECL) $(EXECLE) $(EXECLP) $(EXECV) $(EXECVE) $(EXECVP) $(FORK) $(GETPRIORITY) $(NICE) $(PAUSE) $(PCLOSE) $(PIPE) $(POPEN) $(SETPRIORITY) $(SYSTEM) $(EXECL): $(EXECL).o $(GCC) -o $(EXECL) obj/$(EXECL).o $(LDFLAGS) $(EXECL).o: $(GCC) -o obj/$(EXECL).o -c $(EXECL).c $(CFLAGS) $(EXECLE): $(EXECLE).o $(GCC) -o $(EXECLE) obj/$(EXECLE).o $(LDFLAGS) $(EXECLE).o: $(GCC) -o obj/$(EXECLE).o -c $(EXECLE).c $(CFLAGS) $(EXECLP): $(EXECLP).o $(GCC) -o $(EXECLP) obj/$(EXECLP).o $(LDFLAGS) $(EXECLP).o: $(GCC) -o obj/$(EXECLP).o -c $(EXECLP).c $(CFLAGS) $(EXECV): $(EXECV).o $(GCC) -o $(EXECV) obj/$(EXECV).o $(LDFLAGS) $(EXECV).o: $(GCC) -o obj/$(EXECV).o -c $(EXECV).c $(CFLAGS) $(EXECVE): $(EXECVE).o $(GCC) -o $(EXECVE) obj/$(EXECVE).o $(LDFLAGS) $(EXECVE).o: $(GCC) -o obj/$(EXECVE).o -c $(EXECVE).c $(CFLAGS) $(EXECVP): $(EXECVP).o $(GCC) -o $(EXECVP) obj/$(EXECVP).o $(LDFLAGS) $(EXECVP).o: $(GCC) -o obj/$(EXECVP).o -c $(EXECVP).c $(CFLAGS) $(FORK): $(FORK).o $(GCC) -o $(FORK) obj/$(FORK).o $(LDFLAGS) $(FORK).o: $(GCC) -o obj/$(FORK).o -c $(FORK).c $(CFLAGS) $(GETPRIORITY): $(GETPRIORITY).o $(GCC) -o $(GETPRIORITY) obj/$(GETPRIORITY).o $(LDFLAGS) $(GETPRIORITY).o: $(GCC) -o obj/$(GETPRIORITY).o -c $(GETPRIORITY).c $(CFLAGS) $(NICE): $(NICE).o $(GCC) -o $(NICE) obj/$(NICE).o $(LDFLAGS) $(NICE).o: $(GCC) -o obj/$(NICE).o -c $(NICE).c $(CFLAGS) $(PAUSE): $(PAUSE).o $(GCC) -o $(PAUSE) obj/$(PAUSE).o $(LDFLAGS) $(PAUSE).o: $(GCC) -o obj/$(PAUSE).o -c $(PAUSE).c $(CFLAGS) $(PCLOSE): $(PCLOSE).o $(GCC) -o $(PCLOSE) obj/$(PCLOSE).o $(LDFLAGS) $(PCLOSE).o: $(GCC) -o obj/$(PCLOSE).o -c $(PCLOSE).c $(CFLAGS) $(PIPE): $(PIPE).o $(GCC) -o $(PIPE) obj/$(PIPE).o $(LDFLAGS) $(PIPE).o: $(GCC) -o obj/$(PIPE).o -c $(PIPE).c $(CFLAGS) $(POPEN): $(POPEN).o $(GCC) -o $(POPEN) obj/$(POPEN).o $(LDFLAGS) $(POPEN).o: $(GCC) -o obj/$(POPEN).o -c $(POPEN).c $(CFLAGS) $(SETPRIORITY): $(SETPRIORITY).o $(GCC) -o $(SETPRIORITY) obj/$(SETPRIORITY).o $(LDFLAGS) $(SETPRIORITY).o: $(GCC) -o obj/$(SETPRIORITY).o -c $(SETPRIORITY).c $(CFLAGS) $(SYSTEM): $(SYSTEM).o $(GCC) -o $(SYSTEM) obj/$(SYSTEM).o $(LDFLAGS) $(SYSTEM).o: $(GCC) -o obj/$(SYSTEM).o -c $(SYSTEM).c $(CFLAGS)
#top Predefined Constants¶
#top WAIT_ANY¶
Deklaracja stałej
WAIT_ANY
znajduje się w pliku nagłówkowym sys/wait.h
.Deklaracja stałej
WAIT_ANY
jest następująca:#ifdef __USE_BSD /* Special values for the PID argument to `waitpid()' and `wait4()'. *: # define WAIT_ANY (-1) /* Any process. */ #endif
#top WAIT_MYPGRP¶
Deklaracja stałej
WAIT_MYPGRP
znajduje się w pliku nagłówkowym sys/wait.h
.Deklaracja stałej
WAIT_MYPGRP
jest następująca:#ifdef __USE_BSD /* Special values for the PID argument to `waitpid()' and `wait4()'. *: # define WAIT_MYPGRP 0 /* Any process in my process group. */ #endif
#top WNOHANG¶
Deklaracja stałej
WNOHANG
znajduje się w pliku nagłówkowym bits/waitflags.h
.Deklaracja stałej
WNOHANG
jest następująca:/* Bits in the third argument to `waitpid()'. *: #define WNOHANG 1 /* Don't block waiting. */
#top WUNTRACED¶
Deklaracja stałej
WUNTRACED
znajduje się w pliku nagłówkowym bits/waitflags.h
.Deklaracja stałej
WUNTRACED
jest następująca:/* Bits in the third argument to `waitpid()'. *: #define WUNTRACED 2 /* Report status of stopped children. */
#top P_***¶
Deklaracja stałych
P_***
znajduje się w pliku nagłówkowym sys/wait.h
.Deklaracja stałych
P_***
jest następująca:/* The following values are used by the `waitid()' function. *: #if defined __USE_SVID || defined __USE_XOPEN typedef enum { P_ALL, /* Wait for any child. */ P_PID, /* Wait for specified process. */ P_PGID /* Wait for members of process group. */ } idtype_t; #endif
#top Datatypes / MACROS¶
#top __clock_t¶
Definicja typu
__clock_t
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__clock_t
jest następująca:__STD_TYPE __CLOCK_T_TYPE __clock_t; /* Type of CPU usage counts. */
#top __id_t¶
Definicja typu
__id_t
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__id_t
jest następująca:__STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */
#top __off_t¶
Definicja typu
__off_t
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__off_t
jest następująca:__STD_TYPE __OFF_T_TYPE __off_t; /* Type of file sizes and offsets. */
#top __pid_t¶
Definicja typu
__pid_t
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__pid_t
jest następująca:__STD_TYPE __PID_T_TYPE __pid_t; /* Type of process identifications. */
#top __priority_which_t¶
Definicja typu
__priority_which_t
znajduje się w pliku nagłówkowym sys/resources.h
.Definicja typu
__priority_which_t
jest następująca:#if defined __USE_GNU && !defined __cplusplus [...] typedef enum __priority_which __priority_which_t; #else [...] typedef int __priority_which_t; #endif
#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 __uid_t¶
Definicja typu
__uid_t
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__uid_t
jest następująca:__STD_TYPE __UID_T_TYPE __uid_t; /* Type of user identifications. */
#top __WAIT_STATUS¶
Deklaracja unii
__WAIT_STATUS
znajduje się w pliku nagłówkowym sys/wait.h
.Deklaracja unii
__WAIT_STATUS
jest następująca:# ifdef __USE_BSD [...] /* This is the type of the argument to `wait()'. The funky union causes redeclarations with ether `int *' or `union wait *' to be allowed without complaint. __WAIT_STATUS_DEFN is the type used in the actual function definitions. */ # if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus # define __WAIT_STATUS void * # define __WAIT_STATUS_DEFN void * # else /* This works in GCC 2.6.1 and later. */ typedef union { union wait *__uptr; int *__iptr; } __WAIT_STATUS __attribute__ ((__transparent_union__)); # define __WAIT_STATUS_DEFN int * # endif # else /* Don't use BSD. */ # define __WAIT_INT(status) (status) # define __WAIT_STATUS int * # define __WAIT_STATUS_DEFN int * # endif /* Use BSD. */
#top _G_off_t¶
Definicja typu
_G_off_t
znajduje się w pliku nagłówkowym _G_config.h
.Definicja typu
_G_off_t
jest następująca:#define _G_off_t __off_t
#top _IO_lock_t¶
Definicja typu
_IO_lock_t
znajduje się w pliku nagłówkowym stdio.h
.Definicja typu
_IO_lock_t
jest następująca:/* Handle lock. */ #ifdef _IO_MTSAFE_IO # if defined __GLIBC__ && __GLIBC__ >= 2 # include <bits/stdio-lock.h> # else /*# include <comthread.h>*/ # endif #else typedef void _IO_lock_t; #endif
#top _IO_off_t¶
Definicja typu
_IO_off_t
znajduje się w pliku nagłówkowym stdio.h
.Definicja typu
_IO_off_t
jest następująca:#define _IO_off_t _G_off_t
#top FILE¶
Definicja typu
FILE
znajduje się w pliku nagłówkowym stdio.h
.Definicja typu
FILE
jest następująca:/* The opaque type of streams. This is the definition used elsewhere. */ typedef struct _IO_FILE FILE;
#top id_t¶
Definicja typu
id_t
znajduje się w pliku nagłówkowym sys/resource.h
.Definicja typu
id_t
jest następująca:#ifndef __id_t_defined typedef __id_t id_t; # define __id_t_defined #endif
#top idtype_t¶
Definicja typu
idtype_t
znajduje się w pliku nagłówkowym sys/resource.h
.Definicja typu
idtype_t
jest następująca:/* The following values are used by the `waitid()' function. *: #if defined __USE_SVID || defined __USE_XOPEN typedef enum { P_ALL, /* Wait for any child. */ P_PID, /* Wait for specified process. */ P_PGID /* Wait for members of process group. */ } idtype_t; #endif
#top pid_t¶
Definicja typu
pid_t
znajduje się w pliku nagłówkowym unistd.h
.Definicja typu
pid_t
jest następująca:# ifndef __pid_t_defined typedef __pid_t pid_t; # define __pid_t_defined # endif #endif /* X/Open */
#top siginfo_t¶
Definicja struktury
siginfo_t
znajduje się w pliku nagłówkowym bits/siginfo.h
.Definicja struktury
siginfo_t
jest następująca:typedef struct siginfo { int si_signo; /* Signal number. */ int si_errno; /* If non-zero, an errno value associated with this signal, as defined in <errno.h>. */ int si_code; /* Signal code. */ union { int _pad[__SI_PAD_SIZE]; /* kill(). */ struct { __pid_t si_pid; :* Sending process ID. */ __uid_t si_uid; :* Real user ID of sending process. */ } _kill; /* POSIX.1b timers. */ struct { int si_tid; /* Timer ID. */ int si_overrun; /* Overrun count. */ sigval_t si_sigval; :* Signal value. */ } _timer; /* POSIX.1b signals. */ struct { __pid_t si_pid; :* Sending process ID. */ __uid_t si_uid; :* Real user ID of sending process. */ sigval_t si_sigval; :* Signal value. */ } _rt; /* SIGCHLD. */ struct { __pid_t si_pid; :* Which child. */ __uid_t si_uid; :* Real user ID of sending process. */ int si_status; /* Exit value or signal. */ __clock_t si_utime; __clock_t si_stime; } _sigchld; /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */ struct { void *si_addr; /* Faulting insn/memory ref. */ } _sigfault; /* SIGPOLL. */ struct { long int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; } _sifields; } siginfo_t;
#top sigval_t¶
Definicja unii
sigval_t
znajduje się w pliku nagłówkowym bits/siginfo.h
.Definicja unii
sigval_t
jest następująca:#if (!defined __have_sigval_t \ && (defined _SIGNAL_H || defined __need_siginfo_t \ || defined __need_sigevent_t)) # define __have_sigval_t 1 /* Type for data associated with a signal. */ typedef union sigval { int sival_int; void *sival_ptr; } sigval_t; #endif
#top struct _IO_FILE¶
Definicja struktury
struct _IO_FILE
znajduje się w pliku nagłówkowym libio.h
.Definicja struktury
struct _IO_FILE
jest następująca:struct _IO_FILE { int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ #define _IO_file_flags _flags /* The following pointers correspond to the C++ streambuf protocol. */ /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */ char* _IO_read_ptr; /* Current read pointer */ char* _IO_read_end; /* End of get area. */ char* _IO_read_base; /* Start of putback+get area. */ char* _IO_write_base; /* Start of put area. */ char* _IO_write_ptr; /* Current put pointer. */ char* _IO_write_end; /* End of put area. */ char* _IO_buf_base; /* Start of reserve area. */ char* _IO_buf_end; /* End of reserve area. */ /* The following fields are used to support backing up and undo. */ char *_IO_save_base; /* Pointer to start of non-current get area. */ char *_IO_backup_base; /* Pointer to first valid character of backup area */ char *_IO_save_end; /* Pointer to end of non-current get area. */ struct _IO_marker *_markers; struct _IO_FILE *_chain; int _fileno; #if 0 int _blksize; #else int _flags2; #endif _IO_off_t _old_offset; :* This used to be _offset but it's too small. */ #define __HAVE_COLUMN /* temporary */ /* 1+column number of pbase(); 0 is unknown. */ unsigned short _cur_column; signed char _vtable_offset; char _shortbuf[1]; /* char* _save_gptr; char* _save_egptr; */ _IO_lock_t *_lock; #ifdef _IO_USE_OLD_IO_FILE };
#top struct _IO_marker¶
Definicja struktury
struct _IO_marker
znajduje się w pliku nagłówkowym libio.h
.Definicja struktury
struct _IO_marker
jest następująca:/* A streammarker remembers a position in a buffer. */ struct _IO_marker { struct _IO_marker *_next; struct _IO_FILE *_sbuf; /* If _pos >= 0 it points to _buf->Gbase()+_pos. FIXME comment */ /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */ int _pos; #if 0 void set_streampos(streampos sp) { _spos = sp; } void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); } public: streammarker(streambuf *sb); ~streammarker(); int saving() { return _spos == -2; } int delta(streammarker&); int delta(); #endif };
#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 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 union wait¶
Definicja unii
union wait
znajduje się w pliku nagłówkowym bits/waitstatus.h
.Definicja unii
union wait
jest następująca:#ifdef __USE_BSD # include <endian.h> union wait { int w_status; struct { # if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int __w_termsig:7; /* Terminating signal. */ unsigned int __w_coredump:1; /* Set if dumped core. */ unsigned int __w_retcode:8; /* Return code if exited normally. */ unsigned int:16; # endif /* Little endian. */ # if __BYTE_ORDER == __BIG_ENDIAN unsigned int:16; unsigned int __w_retcode:8; unsigned int __w_coredump:1; unsigned int __w_termsig:7; # endif /* Big endian. */ } __wait_terminated; struct { # if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int __w_stopval:8; /* W_STOPPED if stopped. */ unsigned int __w_stopsig:8; /* Stopping signal. */ unsigned int:16; # endif /* Little endian. */ # if __BYTE_ORDER == __BIG_ENDIAN unsigned int:16; unsigned int __w_stopsig:8; /* Stopping signal. */ unsigned int __w_stopval:8; /* W_STOPPED if stopped. */ # endif /* Big endian. */ } __wait_stopped; }; # define w_termsig __wait_terminated.__w_termsig # define w_coredump __wait_terminated.__w_coredump # define w_retcode __wait_terminated.__w_retcode # define w_stopsig __wait_stopped.__w_stopsig # define w_stopval __wait_stopped.__w_stopval #endif /* Use BSD. */
#top Program execution Functions¶
#top execl¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
execl()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
execl()
jest następująca:/* Execute PATH with all arguments after PATH until a NULL pointer and environment from `environ'. *: extern int execl (__const char *__path, __const char *__arg, ...) __THROW __nonnull ((1));
Powiązane:
execl(), execle(), execlp(), execv(), execve(), execvp(),
Opis:
Funkcja execl()
Argumenty:
const char *__path -
const char *__arg -
... -
Zwracana wartość:
int -
Argumenty:
const char *__path -
const char *__arg -
... -
Zwracana wartość:
int -
Example:
zawartość pliku
execl.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, */ 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 <command> [argv1 [, argv2[, argv3[, argv4]]]]\n", argv[0]); printf("Examples:\n"); printf(" %s /bin/ps\n", argv[0]); printf(" %s /bin/ps f\n", argv[0]); printf(" %s /bin/ps f ax\n", argv[0]); printf(" %s /bin/ps f ax e\n", argv[0]); return 0; } switch (argc) { case 5: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 argv[3]=argv2 argv[4]=argv3 */ result = execl(argv[1], argv[1], argv[2], argv[3], argv[4], NULL); break; case 4: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 argv[3]=argv2 */ result = execl(argv[1], argv[1], argv[2], argv[3], NULL); break; case 3: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 */ result = execl(argv[1], argv[1], argv[2], NULL); break; default: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 */ result = execl(argv[1], argv[1], NULL); break; } printf("%s: Unable to execl(), Reason: %d:%s\n", self, errno, strerror(errno)); /* execl() only returns on error */ exit(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/execute/execlprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/execl <command> [argv1 [, argv2[, argv3[, argv4]]]] Examples: /home/local/code/ansiccode/execute/execl /bin/ps /home/local/code/ansiccode/execute/execl /bin/ps f /home/local/code/ansiccode/execute/execl /bin/ps f ax /home/local/code/ansiccode/execute/execl /bin/ps f ax e
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/execl /bin/ps /home/local/code/ansiccode/execute/execl /bin/ps f axrezultat będzie zależny od podanych argumentów wywołania programu:
PID TTY TIME CMD 3765 pts/43 00:00:00 sh 3767 pts/43 00:00:00 bash 21332 pts/43 00:00:00 ps PID TTY STAT TIME COMMAND 1 ? Ss 0:01 init [5] 2 ? S< 0:00 [migration/0] 3 ? SN 0:00 [ksoftirqd/0] 4 ? S< 0:00 [watchdog/0] 5 ? S< 0:01 [events/0] 6 ? S< 0:00 [khelper] 7 ? S< 0:00 [kthread] 10 ? S< 0:00 \_ [kblockd/0] 11 ? S< 0:00 \_ [kacpid] 99 ? S< 0:00 \_ [cqueue/0] 102 ? S< 0:00 \_ [khubd] 104 ? S< 0:00 \_ [kseriod] 166 ? S 0:00 \_ [pdflush] 167 ? S 0:00 \_ [pdflush] 168 ? S< 0:00 \_ [kswapd0] 169 ? S< 0:00 \_ [aio/0] 325 ? S< 0:00 \_ [kpsmoused] 358 ? S< 0:00 \_ [ata/0] 359 ? S< 0:00 \_ [ata_aux] 362 ? S< 0:00 \_ [scsi_eh_0] 363 ? S< 0:00 \_ [scsi_eh_1] 364 ? S< 0:00 \_ [scsi_eh_2] 365 ? S< 0:00 \_ [scsi_eh_3] 366 ? S< 0:00 \_ [scsi_eh_4] 368 ? S< 0:01 \_ [kjournald] 396 ? S< 0:00 \_ [kauditd] 663 ? S< 0:00 \_ [kgameportd] 1716 ? S< 0:00 \_ [kstriped] 1730 ? S< 0:00 \_ [kmpathd/0] 1731 ? S< 0:00 \_ [kmpath_handlerd] 3491 ? S< 0:00 \_ [kjournald] 3809 ? S< 0:01 \_ [kjournald] 3812 ? S< 0:00 \_ [kjournald] 3815 ? S< 0:00 \_ [kjournald] 3817 ? S< 0:00 \_ [kjournald] 3836 ? S< 0:00 \_ [kjournald] 3838 ? S< 0:00 \_ [kjournald] 3840 ? S< 0:00 \_ [kjournald] 3842 ? S< 0:00 \_ [kjournald] 3844 ? S< 0:00 \_ [kjournald] 3846 ? S< 0:00 \_ [kjournald] 3850 ? S< 0:00 \_ [kjournald] 3852 ? S< 0:00 \_ [kjournald] 434 ? S<s 0:01 /sbin/udevd -d 3854 ? S< 0:00 [loop0] 3858 ? S< 0:00 [loop1] 3861 ? S< 0:00 [loop2] 3864 ? S< 0:00 [loop3] 3866 ? S< 0:00 [loop4] 3867 ? S< 0:00 [loop5] 4450 ? S<sl 0:00 auditd 4452 ? S<sl 0:00 \_ /sbin/audispd 4473 ? Ss 0:00 syslogd -m 0 4476 ? Ss 0:00 klogd -x [...] 3767 pts/43 S 0:00 | \_ /bin/bash 21405 pts/43 R+ 0:00 | \_ /bin/ps f ax [...]
#top execle¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
execle()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
execle()
jest następująca:/* Execute PATH with all arguments after PATH until a NULL pointer and environment from `environ'. *: extern int execl (__const char *__path, __const char *__arg, ...) __THROW __nonnull ((1));
Powiązane:
execl(), execle(), execlp(), execv(), execve(), execvp(),
Opis:
Funkcja execle()
Argumenty:
const char *__path -
const char *__arg -
... -
Zwracana wartość:
int -
Argumenty:
const char *__path -
const char *__arg -
... -
Zwracana wartość:
int -
Example:
zawartość pliku
execle.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, */ int main(int argc, char **argv) { char *self; int result; char *execenv[] = { "ola=122", "ula=ola", NULL }; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <command> [argv1 [, argv2[, argv3[, argv4]]]]\n", argv[0]); printf("Examples:\n"); printf(" %s /bin/ps\n", argv[0]); printf(" %s /bin/ps f\n", argv[0]); printf(" %s /bin/ps f ax\n", argv[0]); printf(" %s /bin/ps f ax e\n", argv[0]); return 0; } switch (argc) { case 5: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 argv[3]=argv2 argv[4]=argv3 */ result = execle(argv[1], argv[1], argv[2], argv[3], argv[4], NULL, execenv); break; case 4: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 argv[3]=argv2 */ result = execle(argv[1], argv[1], argv[2], argv[3], NULL, execenv); break; case 3: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 */ result = execle(argv[1], argv[1], argv[2], NULL, execenv); break; default: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 */ result = execle(argv[1], argv[1], NULL, execenv); break; } printf("%s: Unable to execle(), Reason: %d:%s\n", self, errno, strerror(errno)); /* execve() only returns on error */ exit(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/execute/execleprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/execle <command> [argv1 [, argv2[, argv3[, argv4]]]] Examples: /home/local/code/ansiccode/execute/execle /bin/ps /home/local/code/ansiccode/execute/execle /bin/ps f /home/local/code/ansiccode/execute/execle /bin/ps f ax /home/local/code/ansiccode/execute/execle /bin/ps f ax e
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/execle /bin/ps /home/local/code/ansiccode/execute/execle /bin/ps f axrezultat będzie zależny od podanych argumentów wywołania programu:
PID TTY TIME CMD 3765 pts/43 00:00:00 sh 3767 pts/43 00:00:00 bash 21359 pts/43 00:00:00 ps PID TTY STAT TIME COMMAND 1 ? Ss 0:01 init [5] 2 ? S< 0:00 [migration/0] 3 ? SN 0:00 [ksoftirqd/0] 4 ? S< 0:00 [watchdog/0] 5 ? S< 0:01 [events/0] 6 ? S< 0:00 [khelper] 7 ? S< 0:00 [kthread] 10 ? S< 0:00 \_ [kblockd/0] 11 ? S< 0:00 \_ [kacpid] 99 ? S< 0:00 \_ [cqueue/0] 102 ? S< 0:00 \_ [khubd] 104 ? S< 0:00 \_ [kseriod] 166 ? S 0:00 \_ [pdflush] 167 ? S 0:00 \_ [pdflush] 168 ? S< 0:00 \_ [kswapd0] 169 ? S< 0:00 \_ [aio/0] 325 ? S< 0:00 \_ [kpsmoused] 358 ? S< 0:00 \_ [ata/0] 359 ? S< 0:00 \_ [ata_aux] 362 ? S< 0:00 \_ [scsi_eh_0] 363 ? S< 0:00 \_ [scsi_eh_1] 364 ? S< 0:00 \_ [scsi_eh_2] 365 ? S< 0:00 \_ [scsi_eh_3] 366 ? S< 0:00 \_ [scsi_eh_4] 368 ? S< 0:01 \_ [kjournald] 396 ? S< 0:00 \_ [kauditd] 663 ? S< 0:00 \_ [kgameportd] 1716 ? S< 0:00 \_ [kstriped] 1730 ? S< 0:00 \_ [kmpathd/0] 1731 ? S< 0:00 \_ [kmpath_handlerd] 3491 ? S< 0:00 \_ [kjournald] 3809 ? S< 0:01 \_ [kjournald] 3812 ? S< 0:00 \_ [kjournald] 3815 ? S< 0:00 \_ [kjournald] 3817 ? S< 0:00 \_ [kjournald] 3836 ? S< 0:00 \_ [kjournald] 3838 ? S< 0:00 \_ [kjournald] 3840 ? S< 0:00 \_ [kjournald] 3842 ? S< 0:00 \_ [kjournald] 3844 ? S< 0:00 \_ [kjournald] 3846 ? S< 0:00 \_ [kjournald] 3850 ? S< 0:00 \_ [kjournald] 3852 ? S< 0:00 \_ [kjournald] 434 ? S<s 0:01 /sbin/udevd -d 3854 ? S< 0:00 [loop0] 3858 ? S< 0:00 [loop1] 3861 ? S< 0:00 [loop2] 3864 ? S< 0:00 [loop3] 3866 ? S< 0:00 [loop4] 3867 ? S< 0:00 [loop5] 4450 ? S<sl 0:00 auditd 4452 ? S<sl 0:00 \_ /sbin/audispd 4473 ? Ss 0:00 syslogd -m 0 4476 ? Ss 0:00 klogd -x [...] 3767 pts/43 S 0:00 | \_ /bin/bash 21410 pts/43 R+ 0:00 | \_ /bin/ps f ax [...]
#top execlp¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
execlp()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
execlp()
jest następująca:/* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with all arguments after FILE until a NULL pointer and environment from `environ'. *: extern int execlp (__const char *__file, __const char *__arg, ...) __THROW __nonnull ((1));
Powiązane:
execl(), execle(), execlp(), execv(), execve(), execvp(),
Opis:
Funkcja execlp()
Argumenty:
const char *__file -
const char *__arg -
... -
Zwracana wartość:
int -
Argumenty:
const char *__file -
const char *__arg -
... -
Zwracana wartość:
int -
Example:
zawartość pliku
execlp.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, */ 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 <command> [argv1 [, argv2[, argv3[, argv4]]]]\n", argv[0]); printf("Examples:\n"); printf(" %s ps\n", argv[0]); printf(" %s ps f\n", argv[0]); printf(" %s ps f ax\n", argv[0]); printf(" %s ps f ax e\n", argv[0]); return 0; } switch (argc) { case 5: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 argv[3]=argv2 argv[4]=argv3 */ result = execlp(argv[1], argv[1], argv[2], argv[3], argv[4], NULL); break; case 4: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 argv[3]=argv2 */ result = execlp(argv[1], argv[1], argv[2], argv[3], NULL); break; case 3: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 */ result = execlp(argv[1], argv[1], argv[2], NULL); break; default: /* argv[0]=self, argv[1]=execpath, argv[2]=argv1 */ result = execlp(argv[1], argv[1], NULL); break; } printf("%s: Unable to execlp(), Reason: %d:%s\n", self, errno, strerror(errno)); /* execlp() only returns on error */ exit(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/execute/execlpprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/execlp <command> [argv1 [, argv2[, argv3[, argv4]]]] Examples: /home/local/code/ansiccode/execute/execlp ps /home/local/code/ansiccode/execute/execlp ps f /home/local/code/ansiccode/execute/execlp ps f ax /home/local/code/ansiccode/execute/execlp ps f ax e
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/execlp ps /home/local/code/ansiccode/execute/execlp ps f axrezultat będzie zależny od podanych argumentów wywołania programu:
PID TTY TIME CMD 3765 pts/43 00:00:00 sh 3767 pts/43 00:00:00 bash 21432 pts/43 00:00:00 ps PID TTY STAT TIME COMMAND 1 ? Ss 0:01 init [5] 2 ? S< 0:00 [migration/0] 3 ? SN 0:00 [ksoftirqd/0] 4 ? S< 0:00 [watchdog/0] 5 ? S< 0:01 [events/0] 6 ? S< 0:00 [khelper] 7 ? S< 0:00 [kthread] 10 ? S< 0:00 \_ [kblockd/0] 11 ? S< 0:00 \_ [kacpid] 99 ? S< 0:00 \_ [cqueue/0] 102 ? S< 0:00 \_ [khubd] 104 ? S< 0:00 \_ [kseriod] 166 ? S 0:00 \_ [pdflush] 167 ? S 0:00 \_ [pdflush] 168 ? S< 0:00 \_ [kswapd0] 169 ? S< 0:00 \_ [aio/0] 325 ? S< 0:00 \_ [kpsmoused] 358 ? S< 0:00 \_ [ata/0] 359 ? S< 0:00 \_ [ata_aux] 362 ? S< 0:00 \_ [scsi_eh_0] 363 ? S< 0:00 \_ [scsi_eh_1] 364 ? S< 0:00 \_ [scsi_eh_2] 365 ? S< 0:00 \_ [scsi_eh_3] 366 ? S< 0:00 \_ [scsi_eh_4] 368 ? S< 0:01 \_ [kjournald] 396 ? S< 0:00 \_ [kauditd] 663 ? S< 0:00 \_ [kgameportd] 1716 ? S< 0:00 \_ [kstriped] 1730 ? S< 0:00 \_ [kmpathd/0] 1731 ? S< 0:00 \_ [kmpath_handlerd] 3491 ? S< 0:00 \_ [kjournald] 3809 ? S< 0:01 \_ [kjournald] 3812 ? S< 0:00 \_ [kjournald] 3815 ? S< 0:00 \_ [kjournald] 3817 ? S< 0:00 \_ [kjournald] 3836 ? S< 0:00 \_ [kjournald] 3838 ? S< 0:00 \_ [kjournald] 3840 ? S< 0:00 \_ [kjournald] 3842 ? S< 0:00 \_ [kjournald] 3844 ? S< 0:00 \_ [kjournald] 3846 ? S< 0:00 \_ [kjournald] 3850 ? S< 0:00 \_ [kjournald] 3852 ? S< 0:00 \_ [kjournald] 434 ? S<s 0:01 /sbin/udevd -d 3854 ? S< 0:00 [loop0] 3858 ? S< 0:00 [loop1] 3861 ? S< 0:00 [loop2] 3864 ? S< 0:00 [loop3] 3866 ? S< 0:00 [loop4] 3867 ? S< 0:00 [loop5] 4450 ? S<sl 0:00 auditd 4452 ? S<sl 0:00 \_ /sbin/audispd 4473 ? Ss 0:00 syslogd -m 0 4476 ? Ss 0:00 klogd -x [...] 3767 pts/43 S 0:00 | \_ /bin/bash 21441 pts/43 R+ 0:00 | \_ ps f ax [...]
#top execv¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
execv()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
execv()
jest następująca:/* Execute PATH with arguments ARGV and environment from `environ'. *: extern int execv (__const char *__path, char *__const __argv[]) __THROW __nonnull ((1));
Powiązane:
execl(), execle(), execlp(), execv(), execve(), execvp(),
Opis:
Funkcja execv()
Argumenty:
const char *__path -
char *__const __argv[] -
Zwracana wartość:
int -
Argumenty:
const char *__path -
char *__const __argv[] -
Zwracana wartość:
int -
Example:
zawartość pliku
execv.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, */ int main(int argc, char **argv) { char *self; int result; char *execargv[] = { NULL, NULL, NULL, NULL, NULL }; int argi; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <command> [argv1 [, argv2[, argv3[, argv4]]]]\n", argv[0]); printf("Examples:\n"); printf(" %s /bin/ps\n", argv[0]); printf(" %s /bin/ps f\n", argv[0]); printf(" %s /bin/ps f ax\n", argv[0]); printf(" %s /bin/ps f ax e\n", argv[0]); return 0; } execargv[0] = argv[1]; for (argi=2;argi<argc;argi++) execargv[argi-1] = argv[argi]; result=execv(argv[1], execargv); printf("%s: Unable to execv(), Reason: %d:%s\n", self, errno, strerror(errno)); /* execv() only returns on error */ exit(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/execute/execvprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/execv <command> [argv1 [, argv2[, argv3[, argv4]]]] Examples: /home/local/code/ansiccode/execute/execv /bin/ps /home/local/code/ansiccode/execute/execv /bin/ps f /home/local/code/ansiccode/execute/execv /bin/ps f ax /home/local/code/ansiccode/execute/execv /bin/ps f ax e
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/execv /bin/ps /home/local/code/ansiccode/execute/execv /bin/ps f axrezultat będzie zależny od podanych argumentów wywołania programu:
PID TTY TIME CMD 3765 pts/43 00:00:00 sh 3767 pts/43 00:00:00 bash 21490 pts/43 00:00:00 ps PID TTY STAT TIME COMMAND 1 ? Ss 0:01 init [5] 2 ? S< 0:00 [migration/0] 3 ? SN 0:00 [ksoftirqd/0] 4 ? S< 0:00 [watchdog/0] 5 ? S< 0:01 [events/0] 6 ? S< 0:00 [khelper] 7 ? S< 0:00 [kthread] 10 ? S< 0:00 \_ [kblockd/0] 11 ? S< 0:00 \_ [kacpid] 99 ? S< 0:00 \_ [cqueue/0] 102 ? S< 0:00 \_ [khubd] 104 ? S< 0:00 \_ [kseriod] 166 ? S 0:00 \_ [pdflush] 167 ? S 0:00 \_ [pdflush] 168 ? S< 0:00 \_ [kswapd0] 169 ? S< 0:00 \_ [aio/0] 325 ? S< 0:00 \_ [kpsmoused] 358 ? S< 0:00 \_ [ata/0] 359 ? S< 0:00 \_ [ata_aux] 362 ? S< 0:00 \_ [scsi_eh_0] 363 ? S< 0:00 \_ [scsi_eh_1] 364 ? S< 0:00 \_ [scsi_eh_2] 365 ? S< 0:00 \_ [scsi_eh_3] 366 ? S< 0:00 \_ [scsi_eh_4] 368 ? S< 0:01 \_ [kjournald] 396 ? S< 0:00 \_ [kauditd] 663 ? S< 0:00 \_ [kgameportd] 1716 ? S< 0:00 \_ [kstriped] 1730 ? S< 0:00 \_ [kmpathd/0] 1731 ? S< 0:00 \_ [kmpath_handlerd] 3491 ? S< 0:00 \_ [kjournald] 3809 ? S< 0:01 \_ [kjournald] 3812 ? S< 0:00 \_ [kjournald] 3815 ? S< 0:00 \_ [kjournald] 3817 ? S< 0:00 \_ [kjournald] 3836 ? S< 0:00 \_ [kjournald] 3838 ? S< 0:00 \_ [kjournald] 3840 ? S< 0:00 \_ [kjournald] 3842 ? S< 0:00 \_ [kjournald] 3844 ? S< 0:00 \_ [kjournald] 3846 ? S< 0:00 \_ [kjournald] 3850 ? S< 0:00 \_ [kjournald] 3852 ? S< 0:00 \_ [kjournald] 434 ? S<s 0:01 /sbin/udevd -d 3854 ? S< 0:00 [loop0] 3858 ? S< 0:00 [loop1] 3861 ? S< 0:00 [loop2] 3864 ? S< 0:00 [loop3] 3866 ? S< 0:00 [loop4] 3867 ? S< 0:00 [loop5] 4450 ? S<sl 0:00 auditd 4452 ? S<sl 0:00 \_ /sbin/audispd 4473 ? Ss 0:00 syslogd -m 0 4476 ? Ss 0:00 klogd -x [...] 3767 pts/43 S 0:00 | \_ /bin/bash 21499 pts/43 R+ 0:00 | \_ /bin/ps f ax [...]
#top execve¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
execve()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
execve()
jest następująca:/* Execute PATH with arguments ARGV and environment from `environ'. *: extern int execv (__const char *__path, char *__const __argv[]) __THROW __nonnull ((1));
Powiązane:
execl(), execle(), execlp(), execv(), execve(), execvp(),
Opis:
Funkcja execve()
Argumenty:
const char *__path -
char *__const __argv[] -
Zwracana wartość:
int -
Argumenty:
const char *__path -
char *__const __argv[] -
Zwracana wartość:
int -
Example:
zawartość pliku
execve.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, */ int main(int argc, char **argv) { char *self; int result; char *execargv[] = { NULL, NULL, NULL, NULL, NULL }; char *execenv[] = { "ola=123", NULL }; int argi; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <command> [argv1 [, argv2[, argv3[, argv4]]]]\n", argv[0]); printf("Examples:\n"); printf(" %s /bin/ps\n", argv[0]); printf(" %s /bin/ps f\n", argv[0]); printf(" %s /bin/ps f ax\n", argv[0]); printf(" %s /bin/ps f ax e\n", argv[0]); return 0; } execargv[0] = argv[1]; for (argi=2;argi<argc;argi++) execargv[argi-1] = argv[argi]; result=execve(argv[1], execargv, execenv); printf("%s: Unable to execve(), Reason: %d:%s\n", self, errno, strerror(errno)); /* execve() only returns on error */ exit(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/execute/execveprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/execve <command> [argv1 [, argv2[, argv3[, argv4]]]] Examples: /home/local/code/ansiccode/execute/execve /bin/ps /home/local/code/ansiccode/execute/execve /bin/ps f /home/local/code/ansiccode/execute/execve /bin/ps f ax /home/local/code/ansiccode/execute/execve /bin/ps f ax e
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/execve /bin/ps /home/local/code/ansiccode/execute/execve /bin/ps f axrezultat będzie zależny od podanych argumentów wywołania programu:
PID TTY TIME CMD 3765 pts/43 00:00:00 sh 3767 pts/43 00:00:00 bash 21543 pts/43 00:00:00 ps PID TTY STAT TIME COMMAND 1 ? Ss 0:01 init [5] 2 ? S< 0:00 [migration/0] 3 ? SN 0:00 [ksoftirqd/0] 4 ? S< 0:00 [watchdog/0] 5 ? S< 0:01 [events/0] 6 ? S< 0:00 [khelper] 7 ? S< 0:00 [kthread] 10 ? S< 0:00 \_ [kblockd/0] 11 ? S< 0:00 \_ [kacpid] 99 ? S< 0:00 \_ [cqueue/0] 102 ? S< 0:00 \_ [khubd] 104 ? S< 0:00 \_ [kseriod] 166 ? S 0:00 \_ [pdflush] 167 ? S 0:00 \_ [pdflush] 168 ? S< 0:00 \_ [kswapd0] 169 ? S< 0:00 \_ [aio/0] 325 ? S< 0:00 \_ [kpsmoused] 358 ? S< 0:00 \_ [ata/0] 359 ? S< 0:00 \_ [ata_aux] 362 ? S< 0:00 \_ [scsi_eh_0] 363 ? S< 0:00 \_ [scsi_eh_1] 364 ? S< 0:00 \_ [scsi_eh_2] 365 ? S< 0:00 \_ [scsi_eh_3] 366 ? S< 0:00 \_ [scsi_eh_4] 368 ? S< 0:01 \_ [kjournald] 396 ? S< 0:00 \_ [kauditd] 663 ? S< 0:00 \_ [kgameportd] 1716 ? S< 0:00 \_ [kstriped] 1730 ? S< 0:00 \_ [kmpathd/0] 1731 ? S< 0:00 \_ [kmpath_handlerd] 3491 ? S< 0:00 \_ [kjournald] 3809 ? S< 0:01 \_ [kjournald] 3812 ? S< 0:00 \_ [kjournald] 3815 ? S< 0:00 \_ [kjournald] 3817 ? S< 0:00 \_ [kjournald] 3836 ? S< 0:00 \_ [kjournald] 3838 ? S< 0:00 \_ [kjournald] 3840 ? S< 0:00 \_ [kjournald] 3842 ? S< 0:00 \_ [kjournald] 3844 ? S< 0:00 \_ [kjournald] 3846 ? S< 0:00 \_ [kjournald] 3850 ? S< 0:00 \_ [kjournald] 3852 ? S< 0:00 \_ [kjournald] 434 ? S<s 0:01 /sbin/udevd -d 3854 ? S< 0:00 [loop0] 3858 ? S< 0:00 [loop1] 3861 ? S< 0:00 [loop2] 3864 ? S< 0:00 [loop3] 3866 ? S< 0:00 [loop4] 3867 ? S< 0:00 [loop5] 4450 ? S<sl 0:00 auditd 4452 ? S<sl 0:00 \_ /sbin/audispd 4473 ? Ss 0:00 syslogd -m 0 4476 ? Ss 0:00 klogd -x [...] 3767 pts/43 S 0:00 | \_ /bin/bash 21548 pts/43 R+ 0:00 | \_ /bin/ps f ax [...]
#top execvp¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
execvp()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
execvp()
jest następująca:/* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with arguments ARGV and environment from `environ'. *: extern int execvp (__const char *__file, char *__const __argv[]) __THROW __nonnull ((1));
Powiązane:
execl(), execle(), execlp(), execv(), execve(), execvp(),
Opis:
Funkcja execvp()
Argumenty:
const char *__file -
char *const __argv[] -
Zwracana wartość:
int -
Argumenty:
const char *__file -
char *const __argv[] -
Zwracana wartość:
int -
Example:
zawartość pliku
execvp.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, */ int main(int argc, char **argv) { char *self; int result; char *execargv[] = { NULL, NULL, NULL, NULL, NULL }; int argi; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <command> [argv1 [, argv2[, argv3[, argv4]]]]\n", argv[0]); printf("Examples:\n"); printf(" %s ps\n", argv[0]); printf(" %s ps f\n", argv[0]); printf(" %s ps f ax\n", argv[0]); printf(" %s ps f ax e\n", argv[0]); return 0; } execargv[0] = argv[1]; for (argi=2;argi<argc;argi++) execargv[argi-1] = argv[argi]; result = execvp(argv[1], execargv); printf("%s: Unable to execvp(), Reason: %d:%s\n", self, errno, strerror(errno)); /* execvp() only returns on error */ exit(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/execute/execvpprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/execvp <command> [argv1 [, argv2[, argv3[, argv4]]]] Examples: /home/local/code/ansiccode/execute/execvp ps /home/local/code/ansiccode/execute/execvp ps f /home/local/code/ansiccode/execute/execvp ps f ax /home/local/code/ansiccode/execute/execvp ps f ax e
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/execvp ps /home/local/code/ansiccode/execute/execvp ps f axrezultat będzie zależny od podanych argumentów wywołania programu:
PID TTY TIME CMD 3765 pts/43 00:00:00 sh 3767 pts/43 00:00:00 bash 21574 pts/43 00:00:00 ps PID TTY STAT TIME COMMAND 1 ? Ss 0:01 init [5] 2 ? S< 0:00 [migration/0] 3 ? SN 0:00 [ksoftirqd/0] 4 ? S< 0:00 [watchdog/0] 5 ? S< 0:01 [events/0] 6 ? S< 0:00 [khelper] 7 ? S< 0:00 [kthread] 10 ? S< 0:00 \_ [kblockd/0] 11 ? S< 0:00 \_ [kacpid] 99 ? S< 0:00 \_ [cqueue/0] 102 ? S< 0:00 \_ [khubd] 104 ? S< 0:00 \_ [kseriod] 166 ? S 0:00 \_ [pdflush] 167 ? S 0:00 \_ [pdflush] 168 ? S< 0:00 \_ [kswapd0] 169 ? S< 0:00 \_ [aio/0] 325 ? S< 0:00 \_ [kpsmoused] 358 ? S< 0:00 \_ [ata/0] 359 ? S< 0:00 \_ [ata_aux] 362 ? S< 0:00 \_ [scsi_eh_0] 363 ? S< 0:00 \_ [scsi_eh_1] 364 ? S< 0:00 \_ [scsi_eh_2] 365 ? S< 0:00 \_ [scsi_eh_3] 366 ? S< 0:00 \_ [scsi_eh_4] 368 ? S< 0:01 \_ [kjournald] 396 ? S< 0:00 \_ [kauditd] 663 ? S< 0:00 \_ [kgameportd] 1716 ? S< 0:00 \_ [kstriped] 1730 ? S< 0:00 \_ [kmpathd/0] 1731 ? S< 0:00 \_ [kmpath_handlerd] 3491 ? S< 0:00 \_ [kjournald] 3809 ? S< 0:01 \_ [kjournald] 3812 ? S< 0:00 \_ [kjournald] 3815 ? S< 0:00 \_ [kjournald] 3817 ? S< 0:00 \_ [kjournald] 3836 ? S< 0:00 \_ [kjournald] 3838 ? S< 0:00 \_ [kjournald] 3840 ? S< 0:00 \_ [kjournald] 3842 ? S< 0:00 \_ [kjournald] 3844 ? S< 0:00 \_ [kjournald] 3846 ? S< 0:00 \_ [kjournald] 3850 ? S< 0:00 \_ [kjournald] 3852 ? S< 0:00 \_ [kjournald] 434 ? S<s 0:01 /sbin/udevd -d 3854 ? S< 0:00 [loop0] 3858 ? S< 0:00 [loop1] 3861 ? S< 0:00 [loop2] 3864 ? S< 0:00 [loop3] 3866 ? S< 0:00 [loop4] 3867 ? S< 0:00 [loop5] 4450 ? S<sl 0:00 auditd 4452 ? S<sl 0:00 \_ /sbin/audispd 4473 ? Ss 0:00 syslogd -m 0 4476 ? Ss 0:00 klogd -x [...] 3767 pts/43 S 0:00 | \_ /bin/bash 21579 pts/43 R+ 0:00 | \_ ps f ax [...]
#top fork¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
fork()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
fork()
jest następująca:/* Clone the calling process, creating an exact copy. Return -1 for errors, 0 to the new process, and the process ID of the new process to the old process. */ extern __pid_t fork (void) __THROW;
Powiązane:
fork(), pclose(), pipe(), popen(),
Opis:
Example:
zawartość pliku
fork.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) #else #include <sys/wait.h> /* for typedef enum idtype_t, wait(), waitpid(), */ #endif int main(int argc, char **argv) { char *self; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #else pid_t childpid; pid_t endpid; int status; #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) /* fork() is not available on this OS platform !!! */ printf("%s: fork() is not available on this OS platform !!!\n", self); #else childpid = fork(); if (childpid == -1) { printf("%s: Unable to fork(), Reason: %d:%s\n", self, errno, strerror(errno)); exit(EXIT_FAILURE); } if (childpid == 0) { /* Child process */ printf("%s[%d]: CHILD: sleep(10): child goes sleep for 10 seconds\n", self, (int)childpid); sleep(10); printf("%s[%d]: CHILD: sleep(10): child end sleep\n", self, (int)childpid); exit(0); } else { /* Parent process */ printf("%s[%d]: PARENT: if child sleep(), then parent must wait for child\n", self, (int)childpid); endpid = waitpid(childpid, &status, WUNTRACED); printf("%s[%d]: PARENT: child exited: endpid=%d\n", self, (int)childpid, (int)endpid); } #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/execute/forkprogram wyświetli stosowne informacje o sposobie działania:
fork[0]: CHILD: sleep(10): child goes sleep for 10 seconds fork[21594]: PARENT: if child sleep(), then parent must wait for child fork[0]: CHILD: sleep(10): child end sleep fork[21594]: PARENT: child exited: endpid=21594
#top getpriority¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
getpriority()
znajduje się w pliku nagłówkowym sys/resources.h
.Deklaracja funkcji
getpriority()
jest następująca:/* Return the highest priority of any process specified by WHICH and WHO (see above); if WHO is zero, the current process, process group, or user (as specified by WHO) is used. A lower priority number means higher priority. Priorities range from PRIO_MIN to PRIO_MAX (above). */ extern int getpriority (__priority_which_t __which, id_t __who) __THROW;
Powiązane:
getpriority(), nice(), setpriority(),
Opis:
Example:
zawartość pliku
getpriority.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(), */ #else #endif #if defined(HAVE_GETPRIORITY) || defined(HAVE_SETPRIORITY) #include <sys/resource.h> /* for id_t, __rlimit_resource_t, __rusage_who_t, __priority_which_t, getrlimit(), setrlimit(), getrusage(), getpriority(), setpriority(), */ #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 int main(int argc, char **argv) { char *self; #if defined(HAVE_GETPRIORITY) || defined(HAVE_SETPRIORITY) pid_t priopid; int prioarg; int priores; int result; #endif self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <prio-arg[-19 - +19]> [pid]\n", argv[0]); printf("Examples:\n"); printf(" %s -19\n", argv[0]); printf(" %s -10\n", argv[0]); printf(" %s -5\n", argv[0]); printf(" %s 0\n", argv[0]); printf(" %s 5\n", argv[0]); printf(" %s 10\n", argv[0]); printf(" %s 19\n", argv[0]); return 0; } #if defined(HAVE_GETPRIORITY) || defined(HAVE_SETPRIORITY) prioarg=atoi(argv[1]); if (!(PRIO_MIN<=prioarg && prioarg<=PRIO_MAX)) { printf("%s Bad priority %s, priority should be great %d than and less than %d\n", argv[0], argv[1], PRIO_MIN, PRIO_MAX); return 1; } if (argc>=3) priopid=atoi(argv[2]); else priopid=getpid(); #endif #if defined(HAVE_GETPRIORITY) printf("%s: priores=getpriority(PRIO_PROCESS=%d, %d):\n", self, PRIO_PROCESS, priopid); priores=getpriority(PRIO_PROCESS, priopid); printf("%s: priores=getpriority(PRIO_PROCESS=%d, %d): priores=%d\n", self, PRIO_PROCESS, priopid, priores); #else /* getpriority() is not available on this OS platform !!! */ printf("%s: getpriority() is not available on this OS platform !!!\n", self); #endif #if defined(HAVE_SETPRIORITY) printf("%s: result=setpriority(PRIO_PROCESS=%d, %d, %d):\n", self, PRIO_PROCESS, priopid, prioarg); result=setpriority(PRIO_PROCESS, priopid, prioarg); if (result>=0) printf("%s: result=setpriority(PRIO_PROCESS=%d, %d, %d): result=%d if (result>=0): Successful setpriority()\n", self, PRIO_PROCESS, priopid, prioarg, result); else printf("%s: result=setpriority(PRIO_PROCESS=%d, %d, %d): result=%d if (result>=0): else: Unable to setpriority(), Reason: %d:%s\n", self, PRIO_PROCESS, priopid, prioarg, result, errno, strerror(errno)); #else /* setpriority() is not available on this OS platform !!! */ printf("%s: setpriority() is not available on this OS platform !!!\n", self); #endif #if defined(HAVE_GETPRIORITY) printf("%s: priores=getpriority(PRIO_PROCESS=%d, %d):\n", self, PRIO_PROCESS, priopid); priores=getpriority(PRIO_PROCESS, priopid); printf("%s: priores=getpriority(PRIO_PROCESS=%d, %d): priores=%d\n", self, PRIO_PROCESS, priopid, priores); #else /* getpriority() is not available on this OS platform !!! */ printf("%s: getpriority() is not available on this OS platform !!!\n", self); #endif printf("%s: sleep(30): call\n", self); sleep(30); printf("%s: sleep(30): end.\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/execute/getpriorityprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/getpriority <prio-arg[-19 - +19]> [pid] Examples: /home/local/code/ansiccode/execute/getpriority -19 /home/local/code/ansiccode/execute/getpriority -10 /home/local/code/ansiccode/execute/getpriority -5 /home/local/code/ansiccode/execute/getpriority 0 /home/local/code/ansiccode/execute/getpriority 5 /home/local/code/ansiccode/execute/getpriority 10 /home/local/code/ansiccode/execute/getpriority 19
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/getpriority -19 /home/local/code/ansiccode/execute/getpriority -10 /home/local/code/ansiccode/execute/getpriority -5 /home/local/code/ansiccode/execute/getpriority 0 /home/local/code/ansiccode/execute/getpriority 5 /home/local/code/ansiccode/execute/getpriority 10 /home/local/code/ansiccode/execute/getpriority 19rezultat będzie zależny od podanych argumentów wywołania programu:
getpriority: priores=getpriority(PRIO_PROCESS=0, 6913): getpriority: priores=getpriority(PRIO_PROCESS=0, 6913): priores=0 getpriority: result=setpriority(PRIO_PROCESS=0, 6913, -19): getpriority: result=setpriority(PRIO_PROCESS=0, 6913, -19): result=-1 if (result>=0): else: Unable to setpriority(), Reason: 13:Permission denied getpriority: priores=getpriority(PRIO_PROCESS=0, 6913): getpriority: priores=getpriority(PRIO_PROCESS=0, 6913): priores=0 getpriority: sleep(30): call getpriority: sleep(30): end. getpriority: priores=getpriority(PRIO_PROCESS=0, 6926): getpriority: priores=getpriority(PRIO_PROCESS=0, 6926): priores=0 getpriority: result=setpriority(PRIO_PROCESS=0, 6926, -10): getpriority: result=setpriority(PRIO_PROCESS=0, 6926, -10): result=-1 if (result>=0): else: Unable to setpriority(), Reason: 13:Permission denied getpriority: priores=getpriority(PRIO_PROCESS=0, 6926): getpriority: priores=getpriority(PRIO_PROCESS=0, 6926): priores=0 getpriority: sleep(30): call getpriority: sleep(30): end. getpriority: priores=getpriority(PRIO_PROCESS=0, 6944): getpriority: priores=getpriority(PRIO_PROCESS=0, 6944): priores=0 getpriority: result=setpriority(PRIO_PROCESS=0, 6944, -5): getpriority: result=setpriority(PRIO_PROCESS=0, 6944, -5): result=-1 if (result>=0): else: Unable to setpriority(), Reason: 13:Permission denied getpriority: priores=getpriority(PRIO_PROCESS=0, 6944): getpriority: priores=getpriority(PRIO_PROCESS=0, 6944): priores=0 getpriority: sleep(30): call getpriority: sleep(30): end. getpriority: priores=getpriority(PRIO_PROCESS=0, 6982): getpriority: priores=getpriority(PRIO_PROCESS=0, 6982): priores=0 getpriority: result=setpriority(PRIO_PROCESS=0, 6982, 0): getpriority: result=setpriority(PRIO_PROCESS=0, 6982, 0): result=0 if (result>=0): Successful setpriority() getpriority: priores=getpriority(PRIO_PROCESS=0, 6982): getpriority: priores=getpriority(PRIO_PROCESS=0, 6982): priores=0 getpriority: sleep(30): call getpriority: sleep(30): end. getpriority: priores=getpriority(PRIO_PROCESS=0, 6997): getpriority: priores=getpriority(PRIO_PROCESS=0, 6997): priores=0 getpriority: result=setpriority(PRIO_PROCESS=0, 6997, 5): getpriority: result=setpriority(PRIO_PROCESS=0, 6997, 5): result=0 if (result>=0): Successful setpriority() getpriority: priores=getpriority(PRIO_PROCESS=0, 6997): getpriority: priores=getpriority(PRIO_PROCESS=0, 6997): priores=5 getpriority: sleep(30): call getpriority: sleep(30): end. getpriority: priores=getpriority(PRIO_PROCESS=0, 10600): getpriority: priores=getpriority(PRIO_PROCESS=0, 10600): priores=0 getpriority: result=setpriority(PRIO_PROCESS=0, 10600, 10): getpriority: result=setpriority(PRIO_PROCESS=0, 10600, 10): result=0 if (result>=0): Successful setpriority() getpriority: priores=getpriority(PRIO_PROCESS=0, 10600): getpriority: priores=getpriority(PRIO_PROCESS=0, 10600): priores=10 getpriority: sleep(30): call getpriority: sleep(30): end. getpriority: priores=getpriority(PRIO_PROCESS=0, 10613): getpriority: priores=getpriority(PRIO_PROCESS=0, 10613): priores=0 getpriority: result=setpriority(PRIO_PROCESS=0, 10613, 19): getpriority: result=setpriority(PRIO_PROCESS=0, 10613, 19): result=0 if (result>=0): Successful setpriority() getpriority: priores=getpriority(PRIO_PROCESS=0, 10613): getpriority: priores=getpriority(PRIO_PROCESS=0, 10613): priores=19 getpriority: sleep(30): call getpriority: sleep(30): end.
#top nice¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
nice()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
nice()
jest następująca:/* Add INC to priority of the current process. */ extern int nice (int __inc) __THROW __wur;
Powiązane:
getpriority(), nice(), setpriority(),
Opis:
Funkcja nice()
Argumenty:
int __inc -
Zwracana wartość:
int -
Argumenty:
int __inc -
Zwracana wartość:
int -
Example:
zawartość pliku
nice.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, */ int main(int argc, char **argv) { char *self; int nicearg; int result; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <nice-arg[-19 - +19]>\n", argv[0]); printf("Examples:\n"); printf(" %s -19\n", argv[0]); printf(" %s -10\n", argv[0]); printf(" %s -5\n", argv[0]); printf(" %s 0\n", argv[0]); printf(" %s 5\n", argv[0]); printf(" %s 10\n", argv[0]); printf(" %s 19\n", argv[0]); return 0; } nicearg=atoi(argv[1]); result=0; #if defined(HAVE_NICE) printf("%s: result=nice(nicearg=%d):\n", self, nicearg); result=nice(nicearg); if (errno==0) printf("%s: result=nice(nicearg=%d): result=%d if (errno==0): Successful nice\n", self, nicearg, result); else printf("%s: result=nice(nicearg=%d): result=%d if (errno==0):else: Unable to nice, Reason: %d:%s\n", self, nicearg, result, errno, strerror(errno)); printf("%s: sleep(30): call\n", self); sleep(30); printf("%s: sleep(30): end\n", self); #else /* nice() is not available on this OS platform !!! */ printf("%s: nice() 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/execute/niceprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/nice <nice-arg[-19 - +19]> Examples: /home/local/code/ansiccode/execute/nice 0 /home/local/code/ansiccode/execute/nice <nice-arg[-19 - +19]>
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/nice 10rezultat będzie zależny od podanych argumentów wywołania programu:
nice: result=nice(nicearg=10): nice: result=nice(nicearg=10): result=10 if (errno==0): successful nice nice: sleep(30): call nice: sleep(30): endAby dostrzec rezultat należy uważniej przyjrzeć się kodu źródłowemu programu, po wywołaniu funkcji
nice(nicearg);
program wywołuje sleep(30);
, 30 sekund jest to wystarczająca ilość czasu aby wyświetlić listę procesów i sprawdzić priorytet uruchomionego programu. Ponadto należy zwrócić uwagę, że nowo uruchamiane procesy przez program z ustawionym priorytetem będą po uruchomieniu miały ten sam priorytet co proces je wywołujący (do czasu aż program sam nie zmieni priorytetu). Dodatkowo należy zauważyć również, że użytkownicy nie posiadający odpowiednich uprawnień w systemie mogą tylko obniżać priorytet dla procesów których są właścicielami.#top pclose¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
pclose()
znajduje się w pliku nagłówkowym stdio.h
.Deklaracja funkcji
pclose()
jest następująca:/* Close a stream opened by popen and return the status of its child. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int pclose (FILE *__stream);
Powiązane:
fork(), pclose(), pipe(), popen(),
Opis:
#top pipe¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
pipe()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
pipe()
jest następująca:/* Create a one-way communication channel (pipe). If successful, two file descriptors are stored in PIPEDES; bytes written on PIPEDES[1] can be read from PIPEDES[0]. Returns 0 if successful, -1 if not. */ extern int pipe (int __pipedes[2]) __THROW __wur;
Powiązane:
fork(), pclose(), pipe(), popen(),
Opis:
Funkcja pipe()
Argumenty:
int __pipedes[2] -
Zwracana wartość:
int -
Argumenty:
int __pipedes[2] -
Zwracana wartość:
int -
Example:
zawartość pliku
pipe.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, */ int main(int argc, char **argv) { char *self; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #else int fd[2]; int nbytes; pid_t childpid; char buffsend[1024]; char buffrecv[1024]; #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) /* pipe() is not available on this OS platform !!! */ printf("%s: pipe() is not available on this OS platform !!!\n", self); /* fork() is not available on this OS platform !!! */ printf("%s: fork() is not available on this OS platform !!!\n", self); #else pipe(fd); childpid = fork(); if (childpid == -1) { printf("%s: Unable to fork(), Reason: %d:%s\n", self, errno, strerror(errno)); exit(EXIT_FAILURE); } if (childpid == 0) { /* Child process closes up input side of pipe */ close(fd[0]); memset(buffsend, 0x00, sizeof(buffsend)); strncpy(buffsend, "pipe:line1\npipe:line2\npipe:line3\n", sizeof(buffsend)); /* Send "string" through the output side of pipe */ nbytes = write(fd[1], buffsend, strlen(buffsend)); printf("%s[%d]: nbytes = write(fd[1], buffsend, strlen(buffsend)): nbytes=%d\n", self, (int)childpid, nbytes); printf("%s[%d]: buffsend=|%s|\n", self, (int)childpid, buffsend); exit(0); } else { /* Parent process closes up output side of pipe */ close(fd[1]); memset(buffrecv, 0x00, sizeof(buffrecv)); /* Read in a string from the pipe */ nbytes = read(fd[0], buffrecv, sizeof(buffrecv)-1); printf("%s[%d]: nbytes = read(fd[0], buffrecv, sizeof(buffrecv)-1): nbytes=%d\n", self, (int)childpid, nbytes); printf("%s[%d]: buffrecv=|%s|\n", self, (int)childpid, buffrecv); } #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/execute/pipeprogram wyświetli stosowne informacje o sposobie działania:
pipe[0]: nbytes = write(fd[1], buffsend, strlen(buffsend)): nbytes=33 pipe[0]: buffsend=|pipe:line1 pipe:line2 pipe:line3 | pipe[13427]: nbytes = read(fd[0], buffrecv, sizeof(buffrecv)-1): nbytes=33 pipe[13427]: buffrecv=|pipe:line1 pipe:line2 pipe:line3 |
#top popen¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
popen()
znajduje się w pliku nagłówkowym stdio.h
.Deklaracja funkcji
popen()
jest następująca:/* Create a new stream connected to a pipe running the given command. This function is a possible cancellation point and therefore not marked with __THROW. */ extern FILE *popen (__const char *__command, __const char *__modes) __wur;
Powiązane:
fork(), pclose(), pipe(), popen(),
Opis:
Example:
zawartość pliku
popen.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 <errno.h> /* for errno constant, error constants, */ int main(int argc, char **argv) { char *self; FILE *cmds; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <command> [arg1[, arg2[, arg3[, ...]]]]\n", argv[0]); printf("Examples:\n"); printf(" %s \"cat\"\n", argv[0]); printf(" %s \"head -5\"\n", argv[0]); printf(" %s \"tail -5\"\n", argv[0]); printf(" %s \"sed 's/line/NO/g'\"\n", argv[0]); return 0; } printf("%s: %s\n", self, argv[1]); cmds=popen(argv[1], "w"); if (cmds!=NULL) { printf("%s: file=popen(argv[1]=%s, \"w\"); if (file!=NULL): Successful opened pipe to '%s'.\n", self, argv[1], argv[1]); fputs("line1\n", cmds); fputs("line2\n", cmds); fputs("line3\n", cmds); fputs("line4\n", cmds); fputs("line5\n", cmds); fputs("line6\n", cmds); fputs("line7\n", cmds); fputs("line8\n", cmds); fputs("line9\n", cmds); pclose(cmds); } else { printf("%s: file=fopen(argv[1]=%s, \"w+\"); if (file!=NULL): else: Unable to open file '%s', Reason: %d:%s\n", self, argv[1], argv[1], 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/execute/popenprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/popen <command> [arg1[, arg2[, arg3[, ...]]]] Examples: /home/local/code/ansiccode/execute/popen "cat" /home/local/code/ansiccode/execute/popen "head -5" /home/local/code/ansiccode/execute/popen "tail -5" /home/local/code/ansiccode/execute/popen "sed 's/line/NO/g'"
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/popen lsrezultat będzie zależny od podanych argumentów wywołania programu:
popen: ls popen: file=popen(argv[1]=ls, "w"); if (file!=NULL): Successful opened pipe to 'ls'. execl execle execlp execv execve execvp fork Makefile Makefile.fbsd Makefile.sol nice obj pause.c pclose.c pipe.c popen.c system.c execl.c execle.c execlp.c execv.c execve.c execvp.c fork.c Makefile.beos Makefile.obsd Makefile.win nice.c pause pclose pipe popen system
można również uruchomić z innym argumentem:
/home/local/code/ansiccode/execute/popen 'ls -l *.c | head -10'
w rezultacie program wyświetli następujące informacje:
-rw-r--r-- 1 user users 6523 paź 3 22:53 execl.c -rw-r--r-- 1 user users 6618 sie 28 13:58 execle.c -rw-r--r-- 1 user users 6511 sie 28 13:58 execlp.c -rw-r--r-- 1 user users 6144 sie 28 13:58 execv.c -rw-r--r-- 1 user users 6196 sie 28 13:58 execve.c -rw-r--r-- 1 user users 6129 sie 28 13:58 execvp.c -rw-r--r-- 1 user users 3583 paź 6 21:23 fork.c -rw-r--r-- 1 user users 3433 paź 16 18:35 nice.c -rw-r--r-- 1 user users 2696 paź 3 19:57 pause.c lrwxrwxrwx 1 user users 7 paź 3 23:00 pclose.c -> popen.c
można również uruchomić podając jako argument nieistniejący program:
/home/local/code/ansiccode/execute/popen 'not_existed_exec'
w rezultacie program wyświetli następujące informacje:
popen: not_existed_exec sh: not_existed_exec: command not found popen: file=popen(argv[1]=not_existed_exec, "w"); if (file!=NULL): Successful opened pipe to 'not_existed_exec'.
#top setpriority¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
setpriority()
znajduje się w pliku nagłówkowym sys/resources.h
.Deklaracja funkcji
setpriority()
jest następująca:/* Set the priority of all processes specified by WHICH and WHO (see above) to PRIO. Returns 0 on success, -1 on errors. */ extern int setpriority (__priority_which_t __which, id_t __who, int __prio) __THROW;
Powiązane:
getpriority(), nice(), setpriority(),
Opis:
Funkcja setpriority()
Argumenty:
__priority_which_t __which -
id_t __who -
int __prio -
Zwracana wartość:
int -
Argumenty:
__priority_which_t __which -
id_t __who -
int __prio -
Zwracana wartość:
int -
#top system¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
system()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
system()
jest następująca:/* Execute the given line as a shell command. This function is a cancellation point and therefore not marked with __THROW. */ extern int system (__const char *__command) __wur;
Powiązane:
Opis:
Funkcja system()
Argumenty:
const char *__command -
Zwracana wartość:
int -
Argumenty:
const char *__command -
Zwracana wartość:
int -
Example:
zawartość pliku
system.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 <command>\n", argv[0]); printf("Examples:\n"); printf(" %s ps\n", argv[0]); printf(" %s ps f\n", argv[0]); printf(" %s ps f ax\n", argv[0]); printf(" %s \"ps\"\n", argv[0]); printf(" %s \"ps f\"\n", argv[0]); printf(" %s \"ps f ax\"\n", argv[0]); return 0; } printf("%s result=system(\"%s\"): call\n", self, argv[1]); result=system(argv[1]); printf("%s result=system(\"%s\"): result=%d\n", self, argv[1], result); 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/execute/systemprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/execute/system <command> Examples: /home/local/code/ansiccode/execute/system ps /home/local/code/ansiccode/execute/system ps f /home/local/code/ansiccode/execute/system ps f ax /home/local/code/ansiccode/execute/system "ps" /home/local/code/ansiccode/execute/system "ps f" /home/local/code/ansiccode/execute/system "ps f ax"
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/execute/system ps /home/local/code/ansiccode/execute/system ps f /home/local/code/ansiccode/execute/system ps f ax /home/local/code/ansiccode/execute/system "ps f ax"rezultat będzie zależny od podanych argumentów wywołania programu:
system: result=system("ps"): call PID TTY TIME CMD 3765 pts/43 00:00:00 sh 3767 pts/43 00:00:00 bash 22364 pts/43 00:00:00 system 22365 pts/43 00:00:00 ps system: result=system("ps"): result=0 system: result=system("ps"): call PID TTY TIME CMD 3765 pts/43 00:00:00 sh 3767 pts/43 00:00:00 bash 22364 pts/43 00:00:00 system 22365 pts/43 00:00:00 ps system: result=system("ps"): result=0 system: result=system("ps"): call PID TTY TIME CMD 3765 pts/43 00:00:00 sh 3767 pts/43 00:00:00 bash 22364 pts/43 00:00:00 system 22365 pts/43 00:00:00 ps system: result=system("ps"): result=0 system: result=system("ps f ax"): call PID TTY STAT TIME COMMAND 1 ? Ss 0:01 init [5] 2 ? S< 0:00 [migration/0] 3 ? RN 0:00 [ksoftirqd/0] 4 ? S< 0:00 [watchdog/0] 5 ? S< 0:01 [events/0] 6 ? S< 0:00 [khelper] 7 ? S< 0:00 [kthread] 10 ? S< 0:00 \_ [kblockd/0] 11 ? S< 0:00 \_ [kacpid] 99 ? S< 0:00 \_ [cqueue/0] 102 ? S< 0:00 \_ [khubd] 104 ? S< 0:00 \_ [kseriod] 166 ? S 0:00 \_ [pdflush] 167 ? S 0:00 \_ [pdflush] 168 ? S< 0:00 \_ [kswapd0] 169 ? S< 0:00 \_ [aio/0] 325 ? S< 0:00 \_ [kpsmoused] 358 ? S< 0:00 \_ [ata/0] 359 ? S< 0:00 \_ [ata_aux] 362 ? S< 0:00 \_ [scsi_eh_0] 363 ? S< 0:00 \_ [scsi_eh_1] 364 ? S< 0:00 \_ [scsi_eh_2] 365 ? S< 0:00 \_ [scsi_eh_3] 366 ? S< 0:00 \_ [scsi_eh_4] 368 ? S< 0:01 \_ [kjournald] 396 ? S< 0:00 \_ [kauditd] 663 ? S< 0:00 \_ [kgameportd] 1716 ? S< 0:00 \_ [kstriped] 1730 ? S< 0:00 \_ [kmpathd/0] 1731 ? S< 0:00 \_ [kmpath_handlerd] 3491 ? S< 0:00 \_ [kjournald] 3809 ? S< 0:01 \_ [kjournald] 3812 ? S< 0:00 \_ [kjournald] 3815 ? S< 0:00 \_ [kjournald] 3817 ? S< 0:00 \_ [kjournald] 3836 ? S< 0:00 \_ [kjournald] 3838 ? S< 0:00 \_ [kjournald] 3840 ? S< 0:00 \_ [kjournald] 3842 ? S< 0:00 \_ [kjournald] 3844 ? S< 0:00 \_ [kjournald] 3846 ? S< 0:00 \_ [kjournald] 3850 ? S< 0:00 \_ [kjournald] 3852 ? S< 0:00 \_ [kjournald] 434 ? S<s 0:01 /sbin/udevd -d 3854 ? S< 0:00 [loop0] 3858 ? S< 0:00 [loop1] 3861 ? S< 0:00 [loop2] 3864 ? S< 0:00 [loop3] 3866 ? S< 0:00 [loop4] 3867 ? S< 0:00 [loop5] 4450 ? S<sl 0:00 auditd 4452 ? S<sl 0:00 \_ /sbin/audispd 4473 ? Ss 0:00 syslogd -m 0 4476 ? Ss 0:00 klogd -x [...] 3767 pts/43 S 0:00 | \_ /bin/bash 22394 pts/43 S+ 0:00 | \_ /home/local/code/ansiccode/execute/system ps f ax 22395 pts/43 R+ 0:00 | \_ ps f ax [...] system: result=system("ps f ax"): result=0Jak widać na powyższym przykładzie z powodu przekazywania do funkcji
system();
tylko pierwszego argumentu wywołania programu argv[1]
uruchomienie programu wraz z argumentami wymaga przekazania nazwy programu wraz z argumentami ujętych w cudzysłów.#top wait¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
wait()
znajduje się w pliku nagłówkowym sys/wait.h
.Deklaracja funkcji
wait()
jest następująca:#if defined __USE_SVID || defined __USE_XOPEN # define __need_siginfo_t # include <bits/siginfo.h> /* Wait for a childing matching IDTYPE and ID to change the status and place appropriate information in *INFOP. If IDTYPE is P_PID, match any process whose process ID is ID. If IDTYPE is P_PGID, match any process whose process group is ID. If IDTYPE is P_ALL, match any process. If the WNOHANG bit is set in OPTIONS, and that child is not already dead, clear *INFOP and return 0. If successful, store exit code and status in *INFOP. This function is a cancellation point and therefore not marked with __THROW. */ extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop, int __options); #endif
Powiązane:
wait(), wait3(), wait4(), waitid(), waitpid(),
Opis:
Funkcja wait()
Argumenty:
idtype_t __idtype -
__id_t __id -
siginfo_t *__infop -
int __options -
WNOHANG 1 :* Don't block waiting. */
Zwracana wartość:
int -
Argumenty:
idtype_t __idtype -
__id_t __id -
siginfo_t *__infop -
int __options -
WNOHANG 1 :* Don't block waiting. */
Zwracana wartość:
int -
Example:
zawartość pliku
wait.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 wait3¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
wait3()
znajduje się w pliku nagłówkowym sys/wait.h
.Deklaracja funkcji
wait3()
jest następująca:#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED /* This being here makes the prototypes valid whether or not we have already included <sys/resource.h> to define `struct rusage'. *: struct rusage; /* Wait for a child to exit. When one does, put its status in *STAT_LOC and return its process ID. For errors return (pid_t) -1. If USAGE is not nil, store information about the child's resource usage there. If the WUNTRACED bit is set in OPTIONS, return status for stopped children; otherwise don't. */ extern __pid_t wait3 (__WAIT_STATUS __stat_loc, int __options, struct rusage * __usage) __THROW; #endif
Powiązane:
wait(), wait3(), wait4(), waitid(), waitpid(),
Opis:
Funkcja wait3()
Argumenty:
__WAIT_STATUS __stat_loc -
int __options -
WUNTRACED 2 :* Report status of stopped children. */
struct rusage * __usage -
Zwracana wartość:
__pid_t -
Argumenty:
__WAIT_STATUS __stat_loc -
int __options -
WUNTRACED 2 :* Report status of stopped children. */
struct rusage * __usage -
Zwracana wartość:
__pid_t -
Example:
zawartość pliku
wait3.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 wait4¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
wait4()
znajduje się w pliku nagłówkowym sys/wait.h
.Deklaracja funkcji
wait4()
jest następująca:#ifdef __USE_BSD /* This being here makes the prototypes valid whether or not we have already included <sys/resource.h> to define `struct rusage'. *: struct rusage; /* PID is like waitpid(). Other args are like wait3(). *: extern __pid_t wait4 (__pid_t __pid, __WAIT_STATUS __stat_loc, int __options, struct rusage *__usage) __THROW; #endif /* Use BSD. */
Powiązane:
wait(), wait3(), wait4(), waitid(), waitpid(),
Opis:
Funkcja wait4()
Argumenty:
__pid_t __pid -
WAIT_ANY (-1) :* Any process. */
WAIT_MYPGRP 0 :* Any process in my process group. */
__WAIT_STATUS __stat_loc -
int __options -
WNOHANG 1 :* Don't block waiting. */
WUNTRACED 2 :* Report status of stopped children. */
struct rusage *__usage -
Zwracana wartość:
__pid_t -
Argumenty:
__pid_t __pid -
WAIT_ANY (-1) :* Any process. */
WAIT_MYPGRP 0 :* Any process in my process group. */
__WAIT_STATUS __stat_loc -
int __options -
WNOHANG 1 :* Don't block waiting. */
WUNTRACED 2 :* Report status of stopped children. */
struct rusage *__usage -
Zwracana wartość:
__pid_t -
Example:
zawartość pliku
wait4.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 waitid¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
waitid()
znajduje się w pliku nagłówkowym sys/wait.h
.Deklaracja funkcji
waitid()
jest następująca:#if defined __USE_SVID || defined __USE_XOPEN # define __need_siginfo_t # include <bits/siginfo.h> /* Wait for a childing matching IDTYPE and ID to change the status and place appropriate information in *INFOP. If IDTYPE is P_PID, match any process whose process ID is ID. If IDTYPE is P_PGID, match any process whose process group is ID. If IDTYPE is P_ALL, match any process. If the WNOHANG bit is set in OPTIONS, and that child is not already dead, clear *INFOP and return 0. If successful, store exit code and status in *INFOP. This function is a cancellation point and therefore not marked with __THROW. */ extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop, int __options); #endif
Powiązane:
Opis:
Funkcja waitid()
Argumenty:
idtype_t __idtype -
P_ALL, :* Wait for any child. */
P_PID, :* Wait for specified process. */
P_PGID :* Wait for members of process group. */
__id_t __id -
siginfo_t *__infop -
int __options -
WNOHANG 1 :* Don't block waiting. */
WUNTRACED 2 :* Report status of stopped children. */
Zwracana wartość:
int -
Argumenty:
idtype_t __idtype -
P_ALL, :* Wait for any child. */
P_PID, :* Wait for specified process. */
P_PGID :* Wait for members of process group. */
__id_t __id -
siginfo_t *__infop -
int __options -
WNOHANG 1 :* Don't block waiting. */
WUNTRACED 2 :* Report status of stopped children. */
Zwracana wartość:
int -
Example:
zawartość pliku
waitid.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 waitpid¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
waitpid()
znajduje się w pliku nagłówkowym sys/wait.h
.Deklaracja funkcji
waitpid()
jest następująca:/* Wait for a child matching PID to die. If PID is greater than 0, match any process whose process ID is PID. If PID is (pid_t) -1, match any process. If PID is (pid_t) 0, match any process with the same process group as the current process. If PID is less than -1, match any process whose process group is the absolute value of PID. If the WNOHANG bit is set in OPTIONS, and that child is not already dead, return (pid_t) 0. If successful, return PID and store the dead child's status in STAT_LOC. Return (pid_t) -1 for errors. If the WUNTRACED bit is set in OPTIONS, return status for stopped children; otherwise don't. This function is a cancellation point and therefore not marked with __THROW. */ extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
Powiązane:
Opis:
Funkcja waitpid()
Argumenty:
__pid_t __pid -
WAIT_ANY (-1) /* Any process. */
WAIT_MYPGRP 0 /* Any process in my process group. */
int *__stat_loc -
int __options -
WNOHANG 1 :* Don't block waiting. */
WUNTRACED 2 :* Report status of stopped children. */
</pre>
Zwracana wartość:
__pid_t -
Argumenty:
__pid_t __pid -
WAIT_ANY (-1) /* Any process. */
WAIT_MYPGRP 0 /* Any process in my process group. */
int *__stat_loc -
int __options -
WNOHANG 1 :* Don't block waiting. */
WUNTRACED 2 :* Report status of stopped children. */
</pre>
Zwracana wartość:
__pid_t -
Example:
zawartość pliku
waitpid.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:
Zmodyfikowany ostatnio: 2015/10/01 19:46:10 (9 lat temu),
textsize: 150 kB,
htmlsize: 218 kB
Zapraszam do komentowania, zgłaszania sugestii, propozycji, własnych przykładów, ...
Dodaj komentarzKomentarze użytkowników