diff options
author | emersion <contact@emersion.fr> | 2018-02-23 09:54:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-23 09:54:49 +0100 |
commit | bd9583a7e8108ab4fd31fc5ab6f7c1552258fa6e (patch) | |
tree | e4c88ad6280997d893f0e4aaa98b48fb3bcf3678 /examples | |
parent | 1c1b5b1b17519e945097e9ca9a8f7b5a1669a4fe (diff) | |
parent | 6ba1128a72c3779affd82719a19be643a33490a0 (diff) |
Merge pull request #652 from agx/symbols-file
Add symbols file
Diffstat (limited to 'examples')
-rw-r--r-- | examples/screenshot.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/examples/screenshot.c b/examples/screenshot.c index c163df75..7edb7327 100644 --- a/examples/screenshot.c +++ b/examples/screenshot.c @@ -121,12 +121,32 @@ static const struct wl_registry_listener registry_listener = { .global_remove = handle_global_remove, }; +static int backingfile(off_t size) { + static char template[] = "/tmp/wlroots-shared-XXXXXX"; + int fd, ret; + + fd = mkstemp(template); + if (fd < 0) { + return -1; + } + + while ((ret = ftruncate(fd, size)) == EINTR) {} + if (ret < 0) { + close(fd); + return -1; + } + + unlink(template); + return fd; +} + + static struct wl_buffer *create_shm_buffer(int width, int height, void **data_out) { int stride = width * 4; int size = stride * height; - int fd = os_create_anonymous_file(size); + int fd = backingfile(size); if (fd < 0) { fprintf(stderr, "creating a buffer file for %d B failed: %m\n", size); return NULL; |