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

« back to all changes in this revision

Viewing changes to lib/kernel/src/user_sup.erl

  • 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,
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%% 
 
4
%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
 
5
%% 
 
6
%% The contents of this file are subject to the Erlang Public License,
2
7
%% Version 1.1, (the "License"); you may not use this file except in
3
8
%% compliance with the License. You should have received a copy of the
4
9
%% Erlang Public License along with this software. If not, it can be
5
 
%% retrieved via the world wide web at http://www.erlang.org/.
 
10
%% retrieved online at http://www.erlang.org/.
6
11
%% 
7
12
%% Software distributed under the License is distributed on an "AS IS"
8
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
%% the License for the specific language governing rights and limitations
10
15
%% under the License.
11
16
%% 
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
%% %CopyrightEnd%
17
18
%%
18
19
-module(user_sup).
19
20
 
29
30
%% Internal exports.
30
31
-export([init/1, terminate/2, relay/1]).
31
32
 
 
33
-spec start() -> {'error', {'already_started', pid()}} | {'ok', pid()}.
 
34
 
32
35
start() ->
33
36
    supervisor_bridge:start_link(user_sup, []).
34
37
 
 
38
-spec init([]) -> 'ignore' | {'error', 'nouser'} | {'ok', pid(), pid()}.
 
39
 
35
40
init([]) ->
36
41
    case get_user() of
37
42
        nouser ->
58
63
            halt()
59
64
    end.
60
65
 
 
66
-spec relay(pid()) -> no_return().
 
67
 
61
68
relay(Pid) ->
62
69
    register(user, self()),
63
70
    relay1(Pid).
71
78
 
72
79
 
73
80
%%-----------------------------------------------------------------
74
 
%% Sleep awhile in order to let user write all (some) buffered 
 
81
%% Sleep a while in order to let user write all (some) buffered 
75
82
%% information before termination.
76
83
%%-----------------------------------------------------------------
 
84
 
 
85
-spec terminate(term(), pid()) -> 'ok'.
 
86
 
77
87
terminate(_Reason, UserPid) ->
78
88
    receive after 1000 -> ok end,
79
89
    exit(UserPid, kill),
84
94
%% no more than 10 seconds).  This is so the application_controller
85
95
%% is guaranteed that the user is started.
86
96
%%-----------------------------------------------------------------
 
97
 
87
98
start_user(Func,A) ->
88
99
    apply(Func, A),
89
100
    wait_for_user_p(100).
116
127
    check_flags(T, {master, list_to_atom(Node)});
117
128
check_flags([_H | T], User) -> check_flags(T, User);
118
129
check_flags([], User) -> User.
119