aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/ose/erl_main.c
blob: 21cfce94635d7406e62bd67eb99ab8d6d1ed3598 (plain) (blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * %CopyrightBegin%
 *
 * Copyright Ericsson AB 2000-2009. All Rights Reserved.
 *
 * The contents of this file are subject to the Erlang Public License,
 * Version 1.1, (the "License"); you may not use this file except in
 * compliance with the License. You should have received a copy of the
 * Erlang Public License along with this software. If not, it can be
 * retrieved online at http://www.erlang.org/.
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 *
 * %CopyrightEnd%
 */
#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif
#include "sys.h"
#include "erl_vm.h"
#include "global.h"

#include "shell.h"
#include "ramlog.h"
#include "ose_err/ose_err.h"

static PROCESS mainPid;

#ifdef DEBUG
static OSADDRESS err_handler(OSBOOLEAN user_called, OSERRCODE ecode, OSERRCODE extra) {
  fprintf(stderr,"err_handler: %p %p\n",ecode,extra);
  return 1;
}
#endif

static int
cmd_ek(int argc, char **argv) {
   kill_proc(mainPid);
   return 0;
}

static int
cmd_erl_start(int argc, char **argv) {
   ramlog_printf("\n");
   ramlog_printf("================================================================\n");
   ramlog_printf("\n");
#ifdef DEBUG
   create_error_handler(get_bid(current_process()),err_handler,0x100);
#endif
   erl_start(argc, argv);
   return 0;
}

int
main(int argc, char **argv) {
   mainPid = current_process();

   shell_add_cmd_attrs("start_beam", "start_beam [params]", "Start the Erlang VM",
                       cmd_erl_start, OS_PRI_PROC, 20, 0xF000);

   shell_add_cmd_attrs("ek", "ek", "Kills the Erlang VM",
                       cmd_ek, OS_PRI_PROC, 20, 0x100);

   stop(current_process());

   return 0;
}