toaruos/userspace/shmtest.c
Kevin Lange 5249138dcd Environment variables, integrated with newlib.
* Patched crt0 to support a pre_main
* pre_main sets up environment variables, can do other things later,
  but then just jumps to main with the same arguments.
* Updated a bunch of apps to pass environment variables around.
2012-10-08 00:17:50 -07:00

37 lines
632 B
C

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