1
/* ``The contents of this file are subject to the Erlang Public License,
2
* Version 1.1, (the "License"); you may not use this file except in
3
* compliance with the License. You should have received a copy of the
4
* Erlang Public License along with this software. If not, it can be
5
* retrieved via the world wide web at http://www.erlang.org/.
7
* Software distributed under the License is distributed on an "AS IS"
8
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
* the License for the specific language governing rights and limitations
12
* The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
* Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
* AB. All Rights Reserved.''
21
#include "dbgprintf.h"
27
#include "erl_port_signals.sig"
28
#include "ose_erl_port_prog.h"
33
struct PortData portData;
36
ERL_PORT_PROG(erl_port_prog_ex1) {
37
static const SIGSELECT recv[] = {2, OS_ATTACH_SIG, PORT_DATA};
41
if(!hunt("erts", 0, &erts_, NULL)) {
42
fprintf(stderr, "PORT PROCESS: Fail to read ERTS pid, closing!\n");
43
kill_proc(current_process());
48
sig = receive((SIGSELECT*)recv);
53
fprintf(stderr, "PORT PROCESS: ERTS process terminated, closing!\n");
54
ERL_PORT_PROG_UNREG(erl_port_prog_ex1);
55
kill_proc(current_process());
59
if(strcmp(sig->portData.buf, "stop") == 0) {
60
printf("PORT PROCESS: stopped by user!\n");
61
ERL_PORT_PROG_UNREG(erl_port_prog_ex1);
62
kill_proc(current_process());
64
/* echo the message */
71
/* ------------- LM INIT PROCESSES ------------ */
73
/* register port program from static process */
74
OS_PROCESS(erl_port_prog_ex1_reg) {
75
ERL_PORT_PROG_DECL(erl_port_prog_ex1);
76
ERL_PORT_PROG_REG(erl_port_prog_ex1);
77
stop(current_process());
80
/* good for nothing LM init process */
81
OS_PROCESS(erl_port_prog_ex1_main) {
82
stop(current_process());