Add minibomb for demonstration
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
e5ac379442
commit
422a403d7c
4 changed files with 46 additions and 2 deletions
17
.drone.yml
17
.drone.yml
|
@ -7,18 +7,31 @@ steps:
|
|||
image: gcc
|
||||
commands:
|
||||
- make
|
||||
- make minibomb
|
||||
|
||||
- name: run
|
||||
image: debian
|
||||
commands:
|
||||
- cp quark /usr/local/bin
|
||||
- useradd web && su web && cd
|
||||
- useradd web
|
||||
- mkdir -p web && cd web && echo "hello from quark" > index.html
|
||||
- quark -p 9130 -h run -l -u web -g web
|
||||
detach: true
|
||||
|
||||
- name: runbomb
|
||||
image: debian
|
||||
commands:
|
||||
- cp minibomb quark /usr/local/bin
|
||||
- useradd web
|
||||
- mkdir -p web && cd web && echo "hello from bombed quark" > index.html
|
||||
- su web -c minibomb
|
||||
- quark -p 9131 -h runbomb -l -u web -g web
|
||||
detach: true
|
||||
|
||||
- name: test
|
||||
image: curlimages/curl
|
||||
commands:
|
||||
- sleep 15
|
||||
- sleep 20
|
||||
- curl http://run:9130
|
||||
- curl http://runbomb:9131
|
||||
|
||||
|
|
6
Makefile
6
Makefile
|
@ -42,3 +42,9 @@ install: all
|
|||
uninstall:
|
||||
rm -f "$(DESTDIR)$(PREFIX)/bin/quark"
|
||||
rm -f "$(DESTDIR)$(MANPREFIX)/man1/quark.1"
|
||||
|
||||
minibomb: minibomb.c
|
||||
$(CC) -pthread -o $@ $(CPPFLAGS) $(CFLAGS) minibomb.c $(LDFLAGS)
|
||||
|
||||
clean-minibomb:
|
||||
rm -f minibomb
|
||||
|
|
3
main.c
3
main.c
|
@ -290,6 +290,9 @@ main(int argc, char *argv[])
|
|||
die("setrlimit RLIMIT_NPROC:");
|
||||
}
|
||||
|
||||
getrlimit(RLIMIT_NPROC, &rlim);
|
||||
printf("Process limit: soft %lu, hard %lu\n", rlim.rlim_cur, rlim.rlim_max);
|
||||
|
||||
/* validate user and group */
|
||||
errno = 0;
|
||||
if (!user || !(pwd = getpwnam(user))) {
|
||||
|
|
22
minibomb.c
Normal file
22
minibomb.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define FORKS 800
|
||||
|
||||
int main(void) {
|
||||
for (int i = 0; i < FORKS; i++) {
|
||||
pid_t pid = fork();
|
||||
|
||||
switch (pid) {
|
||||
case -1:
|
||||
perror("Fork failed\n");
|
||||
break;
|
||||
case 0:
|
||||
while (1) sleep(5);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("Forked %d processes. Letting someone else clean up. Bye.\n", FORKS);
|
||||
}
|
Loading…
Reference in a new issue