Moving POSIX system call and library functions out of core Octave

In the last Online Developer Meeting, we briefly discussed moving POSIX functions out of core Octave and into a separate package. Is there any objection to doing that?

Whatever we decide about moving them out of core Octave, it might be useful to more them into a +package namespace.

Here is a list of functions to consider (they might not all strictly be POSIX functions, but they are low-level OS functions that I don’t think are part of core Matlab). We use the ones marked with * in core Octave (28 out of 79 total functions). Are there others I’ve missed?

    F_DUPFD     S_ISCHR       WUNTRACED                gethostname  mktime*
    F_GETFD     S_ISDIR*      __fnmatch__              getpgrp      pipe*
    F_GETFL     S_ISFIFO      __wglob__*               getpid*      popen2*
    F_SETFD     S_ISLNK*      canonicalize_file_name*  getppid      readdir*
    F_SETFL     S_ISREG*      dup2                     getpwent     readlink
    O_APPEND    S_ISSOCK      endgrent                 getpwnam     setgrent
    O_ASYNC     WCONTINUE     endpwent                 getpwuid*    setpwent
    O_CREAT     WCOREDUMP     exec*                    getrusage*   stat*
    O_EXCL      WEXITSTATUS   fcntl                    getuid*      strftime*
    O_NONBLOCK  WIFCONTINUED  fork                     glob*        strptime*
    O_RDONLY    WIFEXITED     getegid                  gmtime*      symlink
    O_RDWR      WIFSIGNALED   geteuid*                 kill         time*
    O_SYNC      WIFSTOPPED    getgid                   link*        uname*
    O_TRUNC     WNOHANG       getgrent                 localtime*   unlink*
    O_WRONLY    WSTOPSIG      getgrgid                 lstat*       waitpid*
    S_ISBLK     WTERMSIG      getgrnam                 mkfifo*

Well I really like having these functions in Octave. I think it would be weird to have some POSIX functions in core Octave and some relegated to an add-on. But I can adapt if others think it’s the right thing.

In particular, I see that geteuid, getpid, and getuid are marked with *. IMO, it would be best to keep whole categories of functions together, so please consider keeping them together with getegid, getgid, getpgrp, and getppid, for example.

I didn’t mean to suggest that we would remove some functions in a given category and leave otherI just tagged those to show that some are used in Octave. s. Just the opposite: I tagged those to show that some are used in Octave so it could be inconvenient to remove them.

Whether we keep them in core Octave or not, it looks like we could eventually simplify our wrappers and configure script with <filesystem> from C++17.

1 Like

that I don’t think are part of core Matlab

checking which for those files against Matlab 2020b with the following toolboxes:

MATLAB                                                Version 9.9         (R2020b)
Simulink                                              Version 10.2        (R2020b)
Aerospace Blockset                                    Version 4.4         (R2020b)
Aerospace Toolbox                                     Version 3.4         (R2020b)
Antenna Toolbox                                       Version 4.3         (R2020b)
Bioinformatics Toolbox                                Version 4.15        (R2020b)
Communications Toolbox                                Version 7.4         (R2020b)
Computer Vision Toolbox                               Version 9.3         (R2020b)
Control System Toolbox                                Version 10.9        (R2020b)
Curve Fitting Toolbox                                 Version 3.5.12      (R2020b)
DSP System Toolbox                                    Version 9.11        (R2020b)
Data Acquisition Toolbox                              Version 4.2         (R2020b)
Database Toolbox                                      Version 10.0        (R2020b)
Deep Learning Toolbox                                 Version 14.1        (R2020b)
Fixed-Point Designer                                  Version 7.1         (R2020b)
Fuzzy Logic Toolbox                                   Version 2.8         (R2020b)
Global Optimization Toolbox                           Version 4.4         (R2020b)
HDL Verifier                                          Version 6.2         (R2020b)
Image Acquisition Toolbox                             Version 6.3         (R2020b)
Image Processing Toolbox                              Version 11.2        (R2020b)
Instrument Control Toolbox                            Version 4.3         (R2020b)
MATLAB Coder                                          Version 5.1         (R2020b)
MATLAB Compiler                                       Version 8.1         (R2020b)
MATLAB Compiler SDK                                   Version 6.9         (R2020b)
MATLAB Report Generator                               Version 5.9         (R2020b)
Mapping Toolbox                                       Version 5.0         (R2020b)
Optimization Toolbox                                  Version 9.0         (R2020b)
Parallel Computing Toolbox                            Version 7.3         (R2020b)
Partial Differential Equation Toolbox                 Version 3.5         (R2020b)
Phased Array System Toolbox                           Version 4.4         (R2020b)
RF Blockset                                           Version 8.0         (R2020b)
RF Toolbox                                            Version 4.0         (R2020b)
Signal Processing Toolbox                             Version 8.5         (R2020b)
Simscape                                              Version 5.0         (R2020b)
Simscape Multibody                                    Version 7.2         (R2020b)
Simulink 3D Animation                                 Version 9.1         (R2020b)
Simulink Design Optimization                          Version 3.9         (R2020b)
Spreadsheet Link                                      Version 3.4.4       (R2020b)
Stateflow                                             Version 10.3        (R2020b)
Statistics and Machine Learning Toolbox               Version 12.0        (R2020b)
Symbolic Math Toolbox                                 Version 8.6         (R2020b)
Wavelet Toolbox                                       Version 5.5         (R2020b)

only the following provided anything other than a ‘not found’:

>> which link
C:\Program Files\MATLAB\R2020b\toolbox\shared\channel\rfprop\@rxsite\link.m  % rxsite method

>> which time
C:\Program Files\MATLAB\R2020b\toolbox\matlab\bigdata\@tall\time.m  % tall method

so correct, none in core Matlab.

I was the one proposing this at the last Developer Meeting, so no surprise that I’m in favor of this.

Although these functions are useful, and essentially free, they are not particularly on-target for numerical computation. If the problem you are solving is more sysadmin-related then maybe a different approach such as shell scripting, Perl, or Python would be a better choice than Octave.

I do think an easy way to finesse this is to put them in a filesystem or POSIX package. Anyone who wants can easily get them, but core Octave doesn’t have to be concerned with them.

In the list that @jwe posted, I see that some names have an asterisk and others are in bold font. Is it possible that the markup language converted some of the asterisks to bold? It makes me unsure which functions actually are being used in core Octave. For example, “symlink” doesn’t have an asterisk for me.

I used the preformatted markup option in the discourse editor. I don’t know why it performs syntax highlighting there or how to disable it. It looks like the * markers are correct in showing the ones that are used in .m files in Octave (symlink is not).

I just hacked it by putting the list inside of a block marked as an Octave code block. Stupid, but it works.