Skip to content

Conversation

@sumukhballal
Copy link
Contributor

Issue number:

Closes #180

Description of changes:

This issue is probably reproducible on every variant (tested on 1) when SIGINT or SIGSTP (or SIGTERM) is called on the build process in a linux host, temp files are not cleared. This is expected behavior as per https://docs.rs/tempfile/latest/tempfile/struct.TempDir.html#resource-leaking as the destructors are never called. The build.rs where these files are created are here.

Instead we will create these files under /tmp as suggested by @webern . This allows us to keep the current build directory clean.

Testing done:

When a SIGINT or SIGSTP (ctrl+c and ctrl+z) is called, I see the file created in the tmp directory. For example:

/tmp/.tmpXYZ

When no such interruption is provided, watching a directory, I see a file created, then deleted eventually when it goes out of scope.

Every 2.0s: ls -a | grep "^\.tmp"                                                                                             Wed May  8 09:45:02 2024

.tmpi6qmGD
.tmpM1RQq1

But eventually it was cleared

Every 2.0s: ls -a | grep "^\.tmp"                                                                                             Wed May  8 09:45:02 2024

.tmpM1RQq1

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

let makefile_path = toolsdir.join("Makefile.toml");
// A temporary directory in the `build` directory
let build_temp_dir = TempDir::new_in(project.project_dir())
let build_temp_dir = TempDir::new_in("/tmp")
Copy link
Contributor

Choose a reason for hiding this comment

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

/tmp can be a memory-backed tmpfs so it is unwise to leak files there - and can be pretty annoying to clean up.

Let's use a path like build/.tmp that we recursively delete and create fresh.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use a path like build/.tmp that we recursively delete and create fresh.

Note that an rm -rf "${BUILDSYS_BUILD_DR}/.tmp" needs to be added to Makefile.toml in the appropriate clean task if we do this here. Also, a create_dir_all is probably required here for the build directory because we are doing these things before we go into cargo make.

@webern
Copy link
Contributor

webern commented Jun 13, 2024

This was fixed by #286

@webern webern closed this Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

twoliter build variant creates a random directory in the project

3 participants