This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yan12125
Recipients christian.heimes, serhiy.storchaka, twouters, vstinner, xdegaye, yan12125
Date 2017-02-22.10:06:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487757962.39.0.441121421384.issue29176@psf.upfronthosting.co.za>
In-reply-to
Content
> Is tmpfile() available on Android?

Yes. Just tried it with Android NDK r13 with clang and API 21 (Android 5.0). Here's the source code test.c:

#include <stdio.h>

int main()
{
    FILE *fp = NULL;
    char c = '\0';

    fp = tmpfile();
    fprintf(fp, "123\n");
    scanf("%c", &c);
    fclose(fp);
    return 0;
}

Compilation command:

/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target aarch64-none-android-linux -gcc-toolchain /opt/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 --sysroot /opt/android-ndk/platforms/android-21/arch-arm64/usr -pie test.c

(didn't test gcc as it's declared as 'deprecated' in NDK)

Before scanf() returns, the temporary file is already deleted:

shell@ASUS_Z00E_2:/ $ ls -l /proc/19300/fd                                     
lrwx------ shell    shell             2017-02-22 15:21 0 -> /dev/pts/0
lrwx------ shell    shell             2017-02-22 15:21 1 -> /dev/pts/0
lrwx------ shell    shell             2017-02-22 15:21 2 -> /dev/pts/0
lrwx------ shell    shell             2017-02-22 15:20 3 -> /data/local/tmp/tmp.VguNf9sqcW (deleted)
lr-x------ shell    shell             2017-02-22 15:21 9 -> /dev/__properties__

For interested, here's its implementation: https://android.googlesource.com/platform/bionic/+/android-5.0.0_r1/libc/bionic/tmpfile.cpp
History
Date User Action Args
2017-02-22 10:06:02yan12125setrecipients: + yan12125, twouters, vstinner, christian.heimes, xdegaye, serhiy.storchaka
2017-02-22 10:06:02yan12125setmessageid: <1487757962.39.0.441121421384.issue29176@psf.upfronthosting.co.za>
2017-02-22 10:06:02yan12125linkissue29176 messages
2017-02-22 10:06:02yan12125create