Giter Club home page Giter Club logo

Comments (6)

dieterdeyke avatar dieterdeyke commented on July 25, 2024 1

from welle.io.

dieterdeyke avatar dieterdeyke commented on July 25, 2024 1

Just to close this issue, I have written a C wrapper using ptys to solve my problem:

#! /usr/bin/tcc -run

/* Author: Dieter Deyke [email protected] /
/
Time-stamp: <2023-02-03 14:48:36 deyke> */

#define _XOPEN_SOURCE 500

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char **argv)
{

char *channel;
char *program;
char *slave_name;
int master_fd;

if (argc != 2 || strncmp(argv[1], "dab://", 6)) {
    fprintf(stderr, "Usage: dabplayer <url>\n");
    exit(1);
}
channel = argv[1] + 6;
if (!(program = strchr(channel, '/'))) {
    fprintf(stderr, "Usage: dabplayer <url>\n");
    exit(1);
}
*program++ = 0;

if ((master_fd = open("/dev/ptmx", O_RDWR, 0600)) < 0) {
    perror("open(\"/dev/ptmx\"");
    exit(1);
}
if (!(slave_name = ptsname(master_fd))) {
    perror("ptsname");
    exit(1);
}
if (unlockpt(master_fd)) {
    perror("unlockpt");
    exit(1);
}

close(0);
if (open(slave_name, O_RDWR) != 0) {
    fprintf(stderr, "stdin fd is not 0\n");
    exit(1);
}

close(1);
if (open("/dev/null", O_RDWR) != 1) {
    fprintf(stderr, "stdout fd is not 1\n");
    exit(1);
}

close(2);
if (open("/dev/null", O_RDWR) != 2) {
    fprintf(stderr, "stderr fd is not 2\n");
    exit(1);
}

execl("/usr/bin/welle-cli", "/usr/bin/welle-cli", "-c", channel, "-p", program, 0);
perror("execl");

return 0;

}

from welle.io.

dieterdeyke avatar dieterdeyke commented on July 25, 2024

I was trying to use welle-cli as a sub-process to an interactive text ui. Leaving stdin unchanged welle-cli stole key strokes intended for the parent process. Connecting stdin to /dev/null made welle-cli block and stall, and connecting stdin to /dev/zero made welle-cli leak memory very fast. Do you have any tips how I can achieve my goal?

from welle.io.

alexmyczko avatar alexmyczko commented on July 25, 2024

@dieterdeyke did you try to use it as documented in /usr/share/doc/welle.io/ ?
https://salsa.debian.org/debian-hamradio-team/welle.io/-/blob/master/debian/README.Debian

from welle.io.

alexmyczko avatar alexmyczko commented on July 25, 2024

@dieterdeyke I haven't tried your code, but if you think it's worth to be added to upstream, why not suggest so (is it maybe useful to others)? Shall I close the issue?

from welle.io.

dieterdeyke avatar dieterdeyke commented on July 25, 2024

from welle.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.