D
Deno

help

getting errno with ffi

Mmxcl6/29/2023
I am using ffi to call execv and need to get the value of errno for failures, but can’t see how I can do that.
IioB6/29/2023
@aapoalas, as the local ffi wizard, do you have any input here?
AAapoAlas6/29/2023
Seems like errno is defined by a macro so I'm not sure it's exactly readable directly with Deno FFI but if it is then it's something like this:
Deno.dlopen("",
{
errno: {
type: "int32"
}
});
Deno.dlopen("",
{
errno: {
type: "int32"
}
});
Hm yeah, seems to be somewhat platform specific. Here's how it'd work for Android:
const lib = Deno.dlopen("",
{
__geterrno: {
parameters: [],
result: "pointer",
},
});

const errnoPointer = lib.symbols.__geterrno();
const errno = new Deno.UnsafePointerView(errnoPointer).getInt32();
const lib = Deno.dlopen("",
{
__geterrno: {
parameters: [],
result: "pointer",
},
});

const errnoPointer = lib.symbols.__geterrno();
const errno = new Deno.UnsafePointerView(errnoPointer).getInt32();
Mmxcl6/29/2023
thanks both!
Deno.dlopen("",
{
errno: {
type: "int32"
}
});
Deno.dlopen("",
{
errno: {
type: "int32"
}
});
works (darwin/vanilla linux)
AAapoAlas6/29/2023
Happy to help! If you have your code up somewhere or put it up later, let me know, I'm interested in seeing all the wonderful and wacky things people come up with using FFI 🙂
IioB6/29/2023
Pretty sure this is for tea curious what this is for specifically though
AAapoAlas6/29/2023
Like brewing?
IioB6/29/2023
GitHub
GitHub - teaxyz/cli: the next-generation, cross‐platform package ma...
the next-generation, cross‐platform package manager - GitHub - teaxyz/cli: the next-generation, cross‐platform package manager
IioB6/29/2023
TLDR; package manager written in Deno https://github.com/teaxyz/cli/pull/621/files oh wow this is a cursed PR
Mmxcl7/9/2023
thanks for the help here both. This use of ffi is now live!
IioB7/9/2023
Happy to help as always Max

Looking for more? Join the community!

Recommended Posts
Purging Kv keysI have a logger which write logs to a kv store with dual keys, something like ```ts kv.set(["logs_bWhat is the right way to bundle native modules?If I'm not able to import a native module with the built-in "import" keyword, what is the ideal way HandleScope in async opIs there a way to get v8::HandleScope inside async op if I add it as ``` scope: &mut v8::HandleScopDeno LSP randomly breaks until a restart (unable to send result to client)This wasnt an issue until recently. In vscode randomly the lsp stops working. Trying to use the autoIs anyone working on LLMs for Deno so I don't have to learn it in disgusting Python?I'm coming to terms with the reality of having to learn this technology but not on Python.. I mean..Permission denied (os error 13)Please help me, I'm desparate. It doesn't print anything else.Is there a rich text (wysiwyg) editor for deno fresh ?I'm working on a blog, and i need a rich text editor for articles.deno_core usageAre there any repos using deno_core in their code + how would I enable the unstable features and URLError reading `allocUnsafe` using npm:icsHello there, I try to use npm:ics in my project and in some runs it works, in others it doesn't (whiUsing discord.js in Deno?Apparently Deno supports discord.js now. Awesome. But now I can't make it work. According to debug Type alias with inherited type parameter constraintsIs there any way to do this? I want SVLTN to just be a short-name alias for SomeVeryLongTypeName, anFresh: global stateIs it possible to have a global state that can be accessed from anywhere? Currently I'm passing the Run Deno on Linux without /proc mountedI have a few automatic scripts using deno to run stuff, and wanted to migrate them to another MachinReasons to choose Node.jsI've been tasked to write a list of pros/cons of Deno in comparison to Node.js. I am quite honestly Reejs not working on Deno v1.34```js deno run -A npm:reejs [INFO] Saving important data... [TIP] If the error indeno.land published the same GitHub tag twicehttps://deno.land/x/smee_client_unofficial@v1.2.3 Could someone please just delete the older one?Uncaught (in promise) eof for websocket/root/.pm2/logs/twitter-follow-checker-error.log last 15 lines: 0|twitter_ | Deno hangs on errorWhy does Deno hang when XML.parse throws an error? ``` let text = '<xml><xbrli:xbrl><hi>Hello</hi><[SOLVED] deno.lock keeps getting populated with dependencies I don't needI have tried to use a syntax highlighter before and have since removed it from my project, but everyWhat a method prefixed with `#` means?This is perhaps the stupidest question ever. But I often see method with names prefixed with a `#`