Skip to content

Instantly share code, notes, and snippets.

@shouichi
Created March 11, 2012 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shouichi/2017510 to your computer and use it in GitHub Desktop.
Save shouichi/2017510 to your computer and use it in GitHub Desktop.
#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;
}
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