mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-04-30 05:25:59 +00:00
pdp10_stdio:fopen/2: silence unwanted crash report on failure; scan_state:fopen/1: likewise
This commit is contained in:
@@ -76,7 +76,10 @@ stdin() ->
|
|||||||
do_fopen(stdin).
|
do_fopen(stdin).
|
||||||
|
|
||||||
do_fopen(File) ->
|
do_fopen(File) ->
|
||||||
gen_server:start(?MODULE, File, []).
|
case gen_server:start(?MODULE, File, []) of
|
||||||
|
{error, {shutdown, Reason}} -> {error, Reason};
|
||||||
|
Result -> Result
|
||||||
|
end.
|
||||||
|
|
||||||
-spec ungetc(byte(), scan_state()) -> ok | {error, {module(), term()}}.
|
-spec ungetc(byte(), scan_state()) -> ok | {error, {module(), term()}}.
|
||||||
ungetc(Ch, Pid) ->
|
ungetc(Ch, Pid) ->
|
||||||
@@ -108,7 +111,9 @@ init(stdin) ->
|
|||||||
init(File) ->
|
init(File) ->
|
||||||
case file:open(File, [raw, read, read_ahead]) of
|
case file:open(File, [raw, read, read_ahead]) of
|
||||||
{ok, IoDev} -> do_init(File, IoDev);
|
{ok, IoDev} -> do_init(File, IoDev);
|
||||||
{error, Reason} -> {stop, {file, Reason}}
|
{error, Reason} ->
|
||||||
|
%% The {shutdown, ...} wrapper prevents an unwanted crash report.
|
||||||
|
{stop, {shutdown, {file, Reason}}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_init(FileName, IoDev) ->
|
do_init(FileName, IoDev) ->
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ fopen(Path, Modes) ->
|
|||||||
do_open(What) ->
|
do_open(What) ->
|
||||||
case gen_server:start(?MODULE, What, []) of
|
case gen_server:start(?MODULE, What, []) of
|
||||||
{ok, Pid} -> {ok, #file{pid = Pid}};
|
{ok, Pid} -> {ok, #file{pid = Pid}};
|
||||||
|
{error, {shutdown, Reason}} -> {error, Reason};
|
||||||
{error, _Reason} = Error -> Error
|
{error, _Reason} = Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@@ -190,8 +191,8 @@ do_init({ok, {IoDev, Read, Write}}) ->
|
|||||||
, iodir = seek
|
, iodir = seek
|
||||||
}};
|
}};
|
||||||
do_init({error, Reason}) ->
|
do_init({error, Reason}) ->
|
||||||
%% FIXME: this still seems to generate crash reports
|
%% The {shutdown, ...} wrapper prevents an unwanted crash report.
|
||||||
{stop, Reason}.
|
{stop, {shutdown, Reason}}.
|
||||||
|
|
||||||
handle_call(Req, _From, State) ->
|
handle_call(Req, _From, State) ->
|
||||||
case Req of
|
case Req of
|
||||||
|
|||||||
Reference in New Issue
Block a user