Created
March 11, 2012 18:17
-
-
Save shouichi/2017510 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <sys/wait.h> | |
int main(void) | |
{ | |
int i, j; | |
int status; | |
pid_t pid; | |
for (i = 0; i < 6; i++) { | |
if ( (pid = fork()) == 0) { | |
for (j = 0;; j++) { | |
} | |
} | |
} | |
while (wait(&status) > 0) { | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PACKAGE = fork | |
SRCS = $(PACKAGE).c | |
OBJS = $(SRCS:.c=.o) | |
FILES = README Makefile $(SRCS) | |
VER = `date +%Y%m%d` | |
### command and flags ### | |
# uncomment when debugging | |
#DEBUG = -ggdb -pg # -lefence | |
LD = gcc | |
LDFLAGS = -g $(DEBUG) | |
LDLIBS = -lm | |
CC = gcc | |
CFLAGS = -g -O2 -Wall $(DEBUG) | |
CPPFLAGS= -I. | |
# etc | |
SHELL = /bin/sh | |
RM = rm -f | |
PROF = gprof | |
### rules ### | |
.SUFFIXES: | |
.SUFFIXES: .o .c | |
all: $(PACKAGE) | |
$(PACKAGE): $(OBJS) | |
$(LD) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS) | |
$(OBJS): Makefile | |
.c.o: | |
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ | |
clean: | |
$(RM) $(PACKAGE) $(OBJS) | |
$(RM) core gmon.out *~ #*# | |
tar: | |
@echo $(PACKAGE)-$(VER) > .package | |
@$(RM) -r `cat .package` | |
@mkdir `cat .package` | |
@ln $(FILES) `cat .package` | |
tar cvf - `cat .package` | gzip -9 > `cat .package`.tar.gz | |
@$(RM) -r `cat .package` .package | |
zip: | |
zip -9 $(PACKAGE)-$(VER).zip $(FILES) | |
run: all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment