Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib: Catch signals to delete tmp folder in local-analyze-images #158

Merged
merged 1 commit into from
Apr 26, 2016

Conversation

Quentin-M
Copy link
Contributor

  • Create the temporary folder earlier in the app (main instead of save)
  • Catch SIGINT/SIGKILL signals to delete the temporary folder and exit

// Analyze the image.
err = AnalyzeLocalImage(imageName, minSeverity, *flagEndpoint, *flagMyAddress, tmpPath)
if err != nil {
log.Print(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this case is going to error, but exit 0

@jzelinskie
Copy link
Contributor

Let's wrap main so that we can return custom errors and get custom exit codes.

package main

import "fmt"
import "os"

func doTheStuff() int {
    defer fmt.Println("!")

    return 3
}

func main() {
    os.Exit(doTheStuff())
}

Let's also block on a select at the bottom of the function waiting for analyzelocalimage or the interrupt

- Create the temporary folder earlier in the app (main instead of save)
- Catch SIGINT/SIGKILL signals to delete the temporary folder and exit
@Quentin-M Quentin-M force-pushed the contrib_cleanup_signals branch from 3180c69 to ff3c6ec Compare April 25, 2016 20:38
@Quentin-M
Copy link
Contributor Author

Meh ^

@jzelinskie
Copy link
Contributor

LGTM

@jzelinskie jzelinskie added kind/bug things are not as they seem reviewed/lgtm labels Apr 26, 2016
@Quentin-M Quentin-M merged commit 01efa56 into quay:master Apr 26, 2016
@Quentin-M Quentin-M deleted the contrib_cleanup_signals branch April 26, 2016 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug things are not as they seem
Development

Successfully merging this pull request may close these issues.

2 participants