Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
e0b05355
Commit
e0b05355
authored
Jun 15, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: If interrupted, Ask is disabled
parent
dc5d2619
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
packer/ui.go
packer/ui.go
+9
-3
No files found.
packer/ui.go
View file @
e0b05355
...
@@ -52,6 +52,7 @@ type ReaderWriterUi struct {
...
@@ -52,6 +52,7 @@ type ReaderWriterUi struct {
Reader
io
.
Reader
Reader
io
.
Reader
Writer
io
.
Writer
Writer
io
.
Writer
l
sync
.
Mutex
l
sync
.
Mutex
interrupted
bool
}
}
func
(
u
*
ColoredUi
)
Ask
(
query
string
)
(
string
,
error
)
{
func
(
u
*
ColoredUi
)
Ask
(
query
string
)
(
string
,
error
)
{
...
@@ -104,6 +105,10 @@ func (rw *ReaderWriterUi) Ask(query string) (string, error) {
...
@@ -104,6 +105,10 @@ func (rw *ReaderWriterUi) Ask(query string) (string, error) {
rw
.
l
.
Lock
()
rw
.
l
.
Lock
()
defer
rw
.
l
.
Unlock
()
defer
rw
.
l
.
Unlock
()
if
rw
.
interrupted
{
return
""
,
errors
.
New
(
"interrupted"
)
}
sigCh
:=
make
(
chan
os
.
Signal
,
1
)
sigCh
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
sigCh
,
os
.
Interrupt
)
signal
.
Notify
(
sigCh
,
os
.
Interrupt
)
defer
signal
.
Stop
(
sigCh
)
defer
signal
.
Stop
(
sigCh
)
...
@@ -129,6 +134,7 @@ func (rw *ReaderWriterUi) Ask(query string) (string, error) {
...
@@ -129,6 +134,7 @@ func (rw *ReaderWriterUi) Ask(query string) (string, error) {
case
line
:=
<-
result
:
case
line
:=
<-
result
:
return
line
,
nil
return
line
,
nil
case
<-
sigCh
:
case
<-
sigCh
:
rw
.
interrupted
=
true
return
""
,
errors
.
New
(
"interrupted"
)
return
""
,
errors
.
New
(
"interrupted"
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment