Skip to content

Commit 2e456d8

Browse files
committed
Init.
0 parents  commit 2e456d8

File tree

8 files changed

+1017
-0
lines changed

8 files changed

+1017
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.*.swp
2+
*.beam
3+
*.plt
4+
subproc.d
5+
/.erlang.mk
6+
/ebin/*.app
7+
/doc/edoc-info
8+
/doc/*.png
9+
/doc/*.html
10+
/doc/*.css

COPYING

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
3-CLAUSE BSD LICENSE
2+
3+
Copyright (c) Stanislaw Klekot.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions
8+
are met:
9+
1. Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
2. Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
3. Neither the names of the copyright holders nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Makefile

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/make -f
2+
3+
#-----------------------------------------------------------------------------
4+
5+
ifeq ($(wildcard .*.plt),)
6+
#DIALYZER_PLT = ~/.dialyzer_plt
7+
else
8+
DIALYZER_PLT = ~/.dialyzer_plt $(wildcard .*.plt)
9+
endif
10+
DIALYZER_OPTS = --no_check_plt $(if $(DIALYZER_PLT),--plts $(DIALYZER_PLT))
11+
12+
DIAGRAMS = $(basename $(notdir $(wildcard diagrams/*.diag)))
13+
DIAGRAMS_SVG = $(foreach D,$(DIAGRAMS),doc/images/$D.svg)
14+
15+
#-----------------------------------------------------------------------------
16+
17+
PROJECT = subproc
18+
APP_VERSION = $(call app-version,ebin/$(PROJECT).app)
19+
ERL_INSTALL_LIB_DIR = $(ERL_LIB_DIR)/$(PROJECT)-$(APP_VERSION)
20+
DOCDIR = /usr/share/doc/erlang-$(PROJECT)
21+
#MANDIR = /usr/share/man
22+
23+
ERLC_OPTS = +debug_info
24+
EDOC_OPTS := {overview, "src/overview.edoc"}, \
25+
{source_path, ["src", "examples"]}, \
26+
todo
27+
ifneq ($(devel),)
28+
EDOC_OPTS := $(EDOC_OPTS), private
29+
endif
30+
31+
include erlang.mk
32+
include erlang.install.mk
33+
34+
#-----------------------------------------------------------------------------
35+
36+
.PHONY: dialyzer
37+
YECC_ERL_FILES = $(subst .yrl,.erl,$(subst .xrl,.erl,$(wildcard src/*.[xy]rl)))
38+
ERL_SOURCE_FILES = $(filter-out $(YECC_ERL_FILES),$(wildcard src/*.erl))
39+
dialyzer:
40+
@echo "dialyzer $(strip $(DIALYZER_OPTS)) --src src/*.erl"
41+
@dialyzer $(strip $(DIALYZER_OPTS)) --src $(ERL_SOURCE_FILES)
42+
43+
#-----------------------------------------------------------------------------
44+
45+
.PHONY: doc
46+
doc: diagrams edoc
47+
48+
.PHONY: diagrams
49+
diagrams: $(DIAGRAMS_SVG)
50+
51+
doc/images/%.svg: diagrams/%.diag
52+
blockdiag -o $@ -T svg $<
53+
54+
#-----------------------------------------------------------------------------
55+
56+
.PHONY: install install-erlang install-doc
57+
58+
install: install-erlang install-doc
59+
60+
install-erlang: app
61+
$(call install-wildcard,644,ebin/*,$(DESTDIR)$(ERL_INSTALL_LIB_DIR)/ebin)
62+
63+
install-doc: edoc
64+
$(call install-wildcard,644,doc/*.html doc/*.png doc/*.css,$(DESTDIR)$(DOCDIR)/html)
65+
66+
#-----------------------------------------------------------------------------
67+
# vim:ft=make

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Unix subprocess manager for Erlang
2+
==================================
3+
4+
`subproc` is a unix subprocess manager for Erlang. It works much closer with
5+
operating systems than Erlang, so over built-in ports it provides several
6+
advantages:
7+
8+
* tracks subprocess' PID
9+
* can spawn a subprocess in a process group
10+
* can send a signal to a subprocess or its process group
11+
* subprocess' STDIO can be intercepted with `pipe(2)` or `socketpair(2)`
12+
* spawned port can work in `{active,once}` and passive modes known from
13+
`gen_tcp` and other socket modules, which provides a sensible backpressure
14+
to external command (running `yes` won't trigger OOM killer)
15+
16+
Contact and License
17+
-------------------
18+
19+
`subproc` library is written by Stanislaw Klekot <dozzie at jarowit.net>.
20+
The primary distribution point is <http://dozzie.jarowit.net/>.
21+
22+
`subproc` library is distributed under 3-clause BSD license. See COPYING file
23+
for details.

build.config

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# erlang.mk bootstrap configuration
2+
3+
# Core modules.
4+
core/core
5+
core/erlc
6+
core/docs # target for plugins/edoc
7+
core/compat # rebar.config
8+
9+
plugins/c_src
10+
#plugins/dialyzer
11+
plugins/edoc

erlang.install.mk

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/make -f
2+
#
3+
# Installation helper for Erlang projects.
4+
# Intended to be used along with erlang.mk.
5+
#
6+
#-----------------------------------------------------------------------------
7+
# variables to be used in main makefile or to be set for functions in next
8+
# sections
9+
10+
ERL_LIB_DIR = $(shell $(ERL) -noinput -eval ' \
11+
io:put_chars([code:lib_dir(), "\n"]), \
12+
halt(). \
13+
')
14+
ESCRIPT_PATH = /usr/bin/escript
15+
16+
#-----------------------------------------------------------------------------
17+
# information reading helpers
18+
19+
# APP_VERSION = $(call app-version,ebin/$(PROJECT).app)
20+
define app-version
21+
$(shell $(ERL) -eval ' \
22+
{ok, AppFile} = init:get_argument(app_file), \
23+
{ok, [{application,_,KeyList}]} = file:consult(AppFile), \
24+
io:put_chars([proplists:get_value(vsn, KeyList), "\n"]), \
25+
halt(). \
26+
' -app_file $1)
27+
endef
28+
29+
#-----------------------------------------------------------------------------
30+
# build rule helpers
31+
32+
# $(call install-wildcard,$(MODE),$(WILDCARD),$(DESTDIR))
33+
define install-wildcard
34+
$(foreach F,$(wildcard $2),$(call install,$1,$F,$3))
35+
endef
36+
37+
# $(call install,$(MODE),$(FILE),$(DESTDIR))
38+
#
39+
# Note that this function preserves the filename. If you need to install the
40+
# file under a different name (e.g. "*.example"), use /usr/bin/install
41+
# directly.
42+
define install
43+
install -D -m $1 $2 $3/$(notdir $2)
44+
45+
endef
46+
47+
# $(call install-escript,$(FILE),$(DESTFILE),$(BEAM_OPTS))
48+
#
49+
# Remember to set in $(BEAM_OPTS) at least "-args_file ...", so the VM args
50+
# can be overriden.
51+
define install-escript
52+
mkdir -p $(dir $2)
53+
printf '#!%s\n%%%%! %s\n' '$(ESCRIPT_PATH)' '$3' > $2
54+
sed -e '1,3{/^#!/d; /^%*!/d}' $1 >> $2
55+
chmod 755 $2
56+
endef
57+
58+
#-----------------------------------------------------------------------------
59+
# vim:ft=make

0 commit comments

Comments
 (0)