Skip to content

[SR-1119] Process.arguments isn't available when 'main' isn't generated by Swift #43732

Closed
@belkadan

Description

@belkadan
Previous ID SR-1119
Radar None
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, StarterBug
Assignee @CodaFi
Priority Medium

md5: 0f34c53480ec273df4a5db445681eff4

Issue Description:

If you have a Swift library that's loaded into a non-Swift executable, or a mixed-source executable whose main function isn't generated from Swift, we never get the chance to set argc and argv on Process, resulting in traps when a client attempts to access them. We should give up on using the "real" argc and argv (i.e. the ones passed to main) and just use _NSGetArgv() on Darwin, /proc/(pid)/cmdline on Linux, and whatever the appropriate API is on FreeBSD, initializing the arguments lazily (and independently from main.

(Alternately, we could put a static initializer in the Swift standard library, at least on Darwin platforms. But static initializers are evil incur a runtime cost on every client, so that's not a great answer.)

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.good first issueGood for newcomersstandard libraryArea: Standard library umbrella

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions