~statik/ubuntu/maverick/erlang/erlang-merge-testing

« back to all changes in this revision

Viewing changes to erts/etc/ose/port_progs/erl_port_ex.c

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-01 10:14:38 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090501101438-6qlr6rsdxgyzrg2z
Tags: 1:13.b-dfsg-2
* Cleaned up patches: removed unneeded patch which helped to support
  different SCTP library versions, made sure that changes for m68k
  architecture applied only when building on this architecture.
* Removed duplicated information from binary packages descriptions.
* Don't require libsctp-dev build-dependency on solaris-i386 architecture
  which allows to build Erlang on Nexenta (thanks to Tim Spriggs for
  the suggestion).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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/.
6
 
 * 
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
10
 
 * under the License.
11
 
 * 
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.''
15
 
 * 
16
 
 *     $Id$
17
 
 */
18
 
 
19
 
#include "ose.h"
20
 
#include "errno.h"
21
 
#include "dbgprintf.h"
22
 
 
23
 
#include "stdlib.h"
24
 
#include "stdio.h"
25
 
#include "string.h"
26
 
 
27
 
#include "erl_port_signals.sig"
28
 
#include "ose_erl_port_prog.h"
29
 
 
30
 
 
31
 
union SIGNAL {
32
 
   SIGSELECT sigNo;
33
 
   struct PortData portData;
34
 
   }; 
35
 
 
36
 
ERL_PORT_PROG(erl_port_prog_ex1) {
37
 
  static const SIGSELECT recv[] = {2, OS_ATTACH_SIG, PORT_DATA};
38
 
  union SIGNAL *sig;
39
 
  PROCESS erts_;
40
 
  
41
 
  if(!hunt("erts", 0, &erts_, NULL)) {
42
 
    fprintf(stderr, "PORT PROCESS: Fail to read ERTS pid, closing!\n");
43
 
    kill_proc(current_process());
44
 
  }
45
 
  attach(NULL, erts_);
46
 
 
47
 
  while(1) {
48
 
    sig = receive((SIGSELECT*)recv);
49
 
    switch(sig->sigNo) {
50
 
    
51
 
    case OS_ATTACH_SIG:
52
 
      free_buf(&sig);
53
 
      fprintf(stderr, "PORT PROCESS: ERTS process terminated, closing!\n");
54
 
      ERL_PORT_PROG_UNREG(erl_port_prog_ex1);
55
 
      kill_proc(current_process());
56
 
      break;
57
 
 
58
 
    case PORT_DATA:
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());
63
 
      } else {
64
 
      /* echo the message */
65
 
      send(&sig, erts_);
66
 
      }
67
 
    }
68
 
  }
69
 
}
70
 
 
71
 
/* ------------- LM INIT PROCESSES ------------ */
72
 
 
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());
78
 
}
79
 
 
80
 
/* good for nothing LM init process */
81
 
OS_PROCESS(erl_port_prog_ex1_main) {
82
 
  stop(current_process());
83
 
}