Skip to content

Build error on Android: call to signal yields "error: function is unused" #3180

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

Closed
marcprux opened this issue Apr 7, 2025 · 2 comments · Fixed by #3181
Closed

Build error on Android: call to signal yields "error: function is unused" #3180

marcprux opened this issue Apr 7, 2025 · 2 comments · Fixed by #3181

Comments

@marcprux
Copy link
Contributor

marcprux commented Apr 7, 2025

#3167 introduced a failure in my hourly Android builds of swift-nio (see https://github.com/swift-everywhere/swift-package-builds/actions/runs/14312839641/job/40111885760), which is a stopgap until swiftlang/github-workflows#106 gets approved.

/Users/runner/work/swift-package-builds/swift-package-builds/swift-nio/Sources/NIOCrashTester/main.swift:140:5: error: function is unused
138 |         try! group.syncShutdownGracefully()
139 |     }
140 |     signal(SIGPIPE, SIG_IGN)
    |     `- error: function is unused

@finagolfin, have you ever seen anything like this?

@marcprux
Copy link
Contributor Author

marcprux commented Apr 7, 2025

I guess because signal is defined as:

sighandler_t _Nonnull signal(int __signal, sighandler_t _Nullable __handler);

and the return value is being treated as a function (which we can presumably ignore), then the solution might be simply:

    #if os(Android)
    _ = signal(SIGPIPE, SIG_IGN)
    #else
    signal(SIGPIPE, SIG_IGN)
    #endif

@finagolfin
Copy link
Contributor

No, never, it is related to the new strict concurrency checking, which was just enabled for this executable in the pull you linked, that just broke my Android CI too and is reproducible natively in Termux. Your linked fix works for me when I just tried it natively on Android.

Why do you think this only hits on Android: is it that these are C macros in linux's signal.h so such type-checking is abandoned there, but is only being performed on Android's more simple C declarations?

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 a pull request may close this issue.

2 participants