~ubuntu-branches/debian/squeeze/erlang/squeeze

« 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-07 15:07:37 UTC
  • mfrom: (1.2.1 upstream) (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090507150737-i4yb5elwinm7r0hc
Tags: 1:13.b-dfsg1-1
* Removed another bunch of non-free RFCs from original tarball
  (closes: #527053).
* Fixed build-dependencies list by adding missing comma. This requires
  libsctp-dev again. Also, added libsctp1 dependency to erlang-base and
  erlang-base-hipe packages because the shared library is loaded via
  dlopen now and cannot be added using dh_slibdeps (closes: #526682).
* Weakened dependency of erlang-webtool on erlang-observer to recommends
  to avoid circular dependencies (closes: #526627).
* Added solaris-i386 to HiPE enabled architectures.
* Made script sources in /usr/lib/erlang/erts-*/bin directory executable,
  which is more convenient if a user wants to create a target Erlang system.
* Shortened extended description line for erlang-dev package to make it
  fit 80x25 terminals.

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
 
}