toaruos/userspace/shmtest.c

37 lines
644 B
C
Raw Normal View History

/*
* shmtest
* It's an shmtest.
*/
2012-02-06 00:16:59 +04:00
#include <sys/types.h>
2012-02-06 05:56:21 +04:00
#include <stdio.h>
#include <stdint.h>
2012-02-06 00:16:59 +04:00
#include <syscall.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
2012-02-06 05:56:21 +04:00
2012-02-06 00:16:59 +04:00
int main (int argc, char ** argv) {
2012-02-06 05:56:21 +04:00
if (argc < 2) {
fprintf(stderr, "%s: expected argument\n", argv[0]);
return 1;
}
2012-02-06 00:16:59 +04:00
char * tokens[] = { NULL, argv[1], NULL };
2012-02-06 05:56:21 +04:00
2012-02-06 00:16:59 +04:00
int pid = getpid();
uint32_t f = fork();
if (getpid() != pid) {
// Child: client
tokens[0] = "/bin/shm_client";
execve(tokens[0], tokens, NULL);
return 3;
} else {
// Parent: server
tokens[0] = "/bin/shm_server";
execve(tokens[0], tokens, NULL);
return 4;
}
2012-02-06 05:56:21 +04:00
return 0;
}