-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
|
||
int main() | ||
{ | ||
char cwd[1024]; | ||
|
||
int status = EXIT_FAILURE; | ||
|
||
if (chdir("/tmp") != 0) | ||
{ | ||
goto end; | ||
} | ||
|
||
if (getcwd(cwd, sizeof(cwd)) == NULL) | ||
{ | ||
goto end; | ||
} | ||
|
||
if (strcmp(cwd, "/tmp") == 0) | ||
{ | ||
status = EXIT_SUCCESS; | ||
} | ||
|
||
end: | ||
printf("%d", status); | ||
exit(status); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$WASMER -q run main.wasm > output | ||
|
||
printf "0" | diff -u output - 1>/dev/null |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sys/epoll.h> | ||
#include <sys/eventfd.h> | ||
#include <unistd.h> | ||
#include <stdint.h> | ||
|
||
int main() | ||
{ | ||
int status = EXIT_FAILURE; | ||
|
||
int efd, epoll_fd; | ||
struct epoll_event event; | ||
struct epoll_event events[1]; | ||
|
||
efd = eventfd(0, 0); | ||
if (efd == -1) | ||
{ | ||
goto end; | ||
} | ||
|
||
epoll_fd = epoll_create1(0); | ||
if (epoll_fd == -1) | ||
{ | ||
goto end; | ||
} | ||
|
||
event.events = EPOLLIN; | ||
event.data.fd = efd; | ||
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, efd, &event) == -1) | ||
{ | ||
goto end; | ||
} | ||
|
||
uint64_t val = 1; | ||
if (write(efd, &val, sizeof(uint64_t)) != sizeof(uint64_t)) | ||
{ | ||
goto end; | ||
} | ||
|
||
int n = epoll_wait(epoll_fd, events, 1, -1); | ||
if (n == -1) | ||
{ | ||
goto end;; | ||
} | ||
|
||
status = EXIT_SUCCESS; | ||
|
||
end: | ||
printf("%d", status); | ||
return status; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$WASMER -q run main.wasm > output | ||
|
||
printf "0" | diff -u output - 1>/dev/null |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/types.h> | ||
#include <sys/socket.h> | ||
#include <unistd.h> | ||
|
||
int main() | ||
{ | ||
int status = EXIT_FAILURE; | ||
|
||
int socks[2]; | ||
char buf[1024]; | ||
ssize_t numRead; | ||
|
||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1) | ||
{ | ||
goto end; | ||
} | ||
|
||
if (write(socks[0], "foo", 3) == -1) | ||
{ | ||
goto end; | ||
} | ||
|
||
memset(buf, 0, sizeof(buf)); | ||
numRead = read(socks[1], buf, sizeof(buf)); | ||
if (numRead == -1) | ||
{ | ||
goto end; | ||
} | ||
if (strncmp(buf, "foo", 3) != 0) | ||
{ | ||
goto end; | ||
} | ||
|
||
if (write(socks[1], "bar", 3) == -1) | ||
{ | ||
goto end; | ||
} | ||
|
||
memset(buf, 0, sizeof(buf)); | ||
numRead = read(socks[0], buf, sizeof(buf)); | ||
if (numRead == -1) | ||
{ | ||
goto end; | ||
} | ||
if (strncmp(buf, "bar", 3) != 0) | ||
{ | ||
goto end; | ||
} | ||
|
||
status = EXIT_SUCCESS; | ||
|
||
end: | ||
printf("%d", status); | ||
return status; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$WASMER -q run main.wasm > output | ||
|
||
printf "0" | diff -u output - 1>/dev/null |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include <signal.h> | ||
#include <sys/wait.h> | ||
|
||
void sig_handler(int signo) | ||
{ | ||
exit(signo != SIGHUP); | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
pid_t pid; | ||
int status; | ||
|
||
pid = fork(); | ||
|
||
if (pid == -1) { | ||
return EXIT_FAILURE; | ||
} else if (pid == 0) { | ||
signal(SIGHUP, sig_handler); | ||
while (1) { | ||
sleep(1); | ||
} | ||
} else { | ||
sleep(1); | ||
|
||
kill(pid, SIGHUP); | ||
|
||
waitpid(pid, &status, 0); | ||
|
||
printf("%d", status); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$WASMER -q run main.wasm > output | ||
|
||
printf "0" | diff -u output - 1>/dev/null |