NSTask's terminate() is not yet implemented on Linux


(Mr Bee) #1

Hi,
I can't use terminate() function of (NS)Task on Linux because it's not yet implemented. I'm using Swift v.3.0.0 on 64-bit Ubuntu 14.04 LTS. Here's the error message upon calling the function:
fatal error: terminate() is not yet implemented: file Foundation/NSTask.swift, line 407 Illegal instruction
So, is there a way to terminate a process that is launched by (NS)Task on Linux? Or has it already implemented on Swift 3.0.2?
Thank you.
Regards,
–Mr Bee


(Will Field-Thompson) #2

From the source

<https://github.com/apple/swift-corelibs-foundation/blob/swift-3.1-branch/Foundation/Process.swift#L422>
and
from status document
<https://github.com/apple/swift-corelibs-foundation/blob/swift-3.1-branch/Docs/Status.md#entities>
(search
"terminate()"), it seems like the answer is that terminate has not yet been
implemented.

Take this with a grain of salt since I haven't tried it out myself, but it
might look something like the following:

import Glibc

kill(task.processIdentifier, SIGTERM)

Where task is your Task (soon to be renamed Process). This isn't exactly
the same as terminate() which I think does some error checking but it gives
you a start.

Good luck!

···

On Tue, Jan 24, 2017 at 12:16 AM Mr Bee via swift-users < swift-users@swift.org> wrote:

Hi,

I can't use terminate() function of (NS)Task on Linux because it's not yet
implemented. I'm using Swift v.3.0.0 on 64-bit Ubuntu 14.04 LTS. Here's the
error message upon calling the function:

fatal error: terminate() is not yet implemented: file Foundation/NSTask.swift, line 407
Illegal instruction

So, is there a way to terminate a process that is launched by (NS)Task on
Linux? Or has it already implemented on Swift 3.0.2?

Thank you.

Regards,

–Mr Bee

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Mr Bee) #3

I see. Thank you for the information and the trick. Yes, it works. Although I'm not sure killing a process is similar to terminating it, I think I can live with it. At least while it's not yet implemented. I mostly use it to terminate a long stucked processes anyway.
Thank you.
Regards,
–Mr Bee

  Tampilkan pesan asli Pada Selasa, 24 Januari 2017 13:45, Will Field-Thompson <will.a.ft@gmail.com> menulis:

From the source and from status document (search "terminate()"), it seems like the answer is that terminate has not yet been implemented.
Take this with a grain of salt since I haven't tried it out myself, but it might look something like the following:

import Glibc
kill(task.processIdentifier, SIGTERM)
Where task is your Task (soon to be renamed Process). This isn't exactly the same as terminate() which I think does some error checking but it gives you a start.
Good luck!

···

On Tue, Jan 24, 2017 at 12:16 AM Mr Bee via swift-users <swift-users@swift.org> wrote:

Hi,
I can't use terminate() function of (NS)Task on Linux because it's not yet implemented. I'm using Swift v.3.0.0 on 64-bit Ubuntu 14.04 LTS. Here's the error message upon calling the function:
fatal error: terminate() is not yet implemented: file Foundation/NSTask.swift, line 407 Illegal instruction
So, is there a way to terminate a process that is launched by (NS)Task on Linux? Or has it already implemented on Swift 3.0.2?
Thank you.
Regards,
–Mr Bee
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Quinn “The Eskimo!”) #4

This (sending a `SIGTERM`) is what you’ll get on Darwin (although the `terminate()` method itself is more complex due to a bunch of bookkeeping requirements).

Share and Enjoy

···

On 24 Jan 2017, at 06:57, Mr Bee via swift-users <swift-users@swift.org> wrote:

Although I'm not sure killing a process is similar to terminating it …

--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware