summaryrefslogtreecommitdiff
path: root/410user/progs/peon.c
blob: 2a37bb5b4e5e0c21fd831f6ac650f2585e7856bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/** @file 410user/progs/peon.c
 *  @author mpa
 *  @brief Tests exec() by launching merchant.
 *  @public yes
 *  @for p3
 *  @covers exec
 *  @status done
 */

#include <syscall.h>
#include <stdio.h>
#include <stddef.h>
#include <simics.h>

int main() {

  int tid = gettid();

  char buf[16];
  char * prog = "merchant";
  char * args[5] = { "merchant", "13", "foo bar", NULL, NULL };

  args[3] = buf;
  sprintf(buf, "%d", tid);

  lprintf("promoting peon #%d to a merchant", tid);

  if (exec(prog, args) < 0)
    lprintf("ABORTING: exec returned error");
  else
    lprintf("ABORTING: exec returned success");

  /* infinite loop as exit may not be implemented */
  while(1);
}