Why is taskset still not in util-linux?

Yaakov Selkowitz yselkowitz@cygwin.com
Sun Mar 22 20:09:59 GMT 2020

On Sat, 2020-03-21 at 01:37 -0700, Mark Geisert wrote:
> Eliot Moss wrote:
> > On 3/20/2020 9:39 AM, Yaakov Selkowitz wrote:
> > 
> >  > Cygwin doesn't support syscalls.  I'd be very wary of any code which is
> >  > conditional on any #ifdef SYS_*.
> > 
> > Of course.  AFAICT taskset does not need the syscall, it just needs the
> > library call to work.  Asking about the syscall is, I suppose, a kind of Linux
> > shorthand to see if something is supported on the particular platform.  Mark's
> > suggestion of providing a fake definition of that syscall definition is a
> > workaround that may disturb the util-linux sources the least.
> What I did here was definitely a hack.  I'm not sure it's the best solution.
> I fully concur with Yaakov's warning.  There's two levels to syscalls as seen in 
> programs like taskset.  On one level, configure checks whether a particular 
> syscall exists on the compiling machine because different Linux kernels have 
> different sets of syscalls.  On the second level, the program actually uses a 
> call named syscall() to call into specific kernel routines.
> On Cygwin, what to do about programs that assume they're running on Linux and so 
> make use of the Linux syscall feature?  We could dummy up a sys/syscall.h but 
> implementing a full syscall() interface would be a lot of work and do nothing 
> but slow down programs making heavy use of it; it adds a layer of indirection.

I have considered doing just that on multiple occasions, but never got
so desperate for it to bother.  Keep in mind that kernel APIs often
vary from their userspace wrappers (which is one of the two reasons
userspace code calls syscall, the other being to access yet-unwrapped
calls), meaning such an implementation wouldn't be a simple mapping to
existing userspace functions.  However, I wouldn't worry so much about
performance, the point would be compatibility.

> Yaakov, do you have a general strategy for dealing with syscall usage when 
> you've come across it in all the porting you've done?  Cygwin-specific patch?

That depends very much on what the code is trying to do (and which
syscalls it wants to call!), but using #ifdef SYS_* to guard use of the
corresponding userspace function call might be a first.  There are
definitely some of my packages which I had to patch around syscall
assumptions, but I'd have to go find them.


More information about the Cygwin mailing list