Lazarus

Free Pascal => Unix => Topic started by: abdoun.brahim on May 11, 2022, 07:16:47 pm

Title: equivalent setpgrp() in lazarus
Post by: abdoun.brahim on May 11, 2022, 07:16:47 pm
Hello
What is the equivalent of the setpgrp() command of the C in lazarus language
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 12, 2022, 09:58:23 am
Note that this is nothing to do with C, it's a unix syscall. Also it's not really anything to do with the Lazarus IDE or the LCL, it's an underlying FPC library issue.

I don't think it's implemented. I can see the syscall number in the sources, but you might need to either import clib or user TCSetPGrp() from termios.

MarkMLl
Title: Re: equivalent setpgrp() in lazarus
Post by: Thaddy on May 12, 2022, 12:49:55 pm
If it is implemented - I am not sure it is - it has an fp prefix since a couple of versions, so fpsetpgrp..
[edit] it is implemented, but maybe not for all platforms. I found it at least in /rtl/netwlibc/libc.pp using grep.

I can't imagine you really want to use netware/nlm, btw. But that is the only one that matched: seems tied to netware libc, not C.
Title: Re: equivalent setpgrp() in lazarus
Post by: abdoun.brahim on May 12, 2022, 01:41:43 pm
Thank you for your help
when I compile I have the error using fpSetPGrp
error:identifier not found "fpsetpgrp"
when I compile I have the error using tcSetPGrp
error:identifier not found "tcsetpgrp"
Title: Re: equivalent setpgrp() in lazarus
Post by: marcov on May 12, 2022, 01:53:32 pm
Possibly the setgroups() in the "grp" unit is doing the same.

Like some other Unix user and group functions, these are in the "user" package and link to libc.
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 12, 2022, 02:20:15 pm
Where's that package documented? I can't find it in any of the pages cited at https://www.freepascal.org/docs.html

Following through to libc stuff, setgroups() is described as "sets the supplementary group IDs for the calling process" which I suspect is not what OP's looking for.

MarkMLl
Title: Re: equivalent setpgrp() in lazarus
Post by: Thausand on May 12, 2022, 02:30:19 pm
Is it not same like fpSetGid (https://www.freepascal.org/docs-html/rtl/baseunix/fpsetgid.html) ?
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 12, 2022, 02:38:38 pm
Is it not same like fpSetGid (https://www.freepascal.org/docs-html/rtl/baseunix/fpsetgid.html) ?

No.

MarkMLl
Title: Re: equivalent setpgrp() in lazarus
Post by: abdoun.brahim on May 12, 2022, 04:19:22 pm
i foud it in unite :termio
Title: Re: equivalent setpgrp() in lazarus
Post by: marcov on May 12, 2022, 04:46:55 pm
If I understand the man page clearly, it is a BSD call that was adapted by Linux, but never standarized under POSIX.
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 12, 2022, 05:06:50 pm
If I understand the man page clearly, it is a BSD call that was adapted by Linux, but never standarized under POSIX.

So presumably at least one of the popular gettys is used by both Linux and the BSDs, which is why it's in termio.

MarkMLl
Title: Re: equivalent setpgrp() in lazarus
Post by: Thaddy on May 13, 2022, 03:41:58 pm
If I understand the man page clearly, it is a BSD call that was adapted by Linux, but never standarized under POSIX.
No it is a netware call. Indeed not standard.
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 13, 2022, 04:14:13 pm
If I understand the man page clearly, it is a BSD call that was adapted by Linux, but never standarized under POSIX.
No it is a netware call. Indeed not standard.

"Up to a point Lord Copper."

https://linux.die.net/man/2/setpgrp

MarkMLl
Title: Re: equivalent setpgrp() in lazarus
Post by: Thaddy on May 13, 2022, 06:57:18 pm
BSD dates from 1993, Netware dates from 1983....Unix relase dates from 1970... That call was introduced by Novell.
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 13, 2022, 07:08:40 pm
And ASCII was introduced by IBM.

I don't care who introduced it: it's supported by Linux and that manpage cites POSIX.1 (with non-standard variations for SysV and BSD).

MarkMLl
Title: Re: equivalent setpgrp() in lazarus
Post by: marcov on May 13, 2022, 10:40:43 pm
And ASCII was introduced by IBM.

I don't care who introduced it: it's supported by Linux and that manpage cites POSIX.1 (with non-standard variations for SysV and BSD).

But not for that call afaik. For other calls on that manpage.
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 13, 2022, 11:00:32 pm
Hmmm. man setpgrp ->

Quote
DESCRIPTION
       All  of these interfaces are available on Linux, and are used for getting and setting the process group ID (PGID) of a process.  The
       preferred, POSIX.1-specified ways of doing this are: getpgrp(void), for retrieving the calling process's PGID;  and  setpgid(),  for
       setting a process's PGID.

and

Quote
The System V-style setpgrp(), which takes no arguments, is equivalent to setpgid(0, 0).

       The BSD-specific setpgrp() call, which takes arguments pid and pgid, is a wrapper function that calls

           setpgid(pid, pgid)

       Since glibc 2.19, the BSD-specific setpgrp() function is no longer  exposed  by  <unistd.h>;  calls  should  be  replaced  with  the
       setpgid() call shown above.

Also in ./rtl/linux/x86_64/sysnr.inc:

Code: Pascal  [Select][+][-]
  1.   syscall_nr_setpgid                           = 109;
  2.   syscall_nr_getppid                           = 110;
  3.   syscall_nr_getpgrp                           = 111;
  4. ...
  5.   syscall_nr_getpgid                           = 121;
  6.  

It looks as though the Netware RTL is the only one to implement FpSetpgid(), which might in practice be what OP's looking for.

MarkMLl
Title: Re: equivalent setpgrp() in lazarus
Post by: marcov on May 13, 2022, 11:12:47 pm
From my debian manpage:

Quote
POSIX.1-2001 also specifies getpgid() and the version of setpgrp() that takes no arguments.  (POSIX.1-2008 marks  this  setpgrp()
       specification as obsolete.)

       The  version of getpgrp() with one argument and the version of setpgrp() that takes two arguments derive from 4.2BSD, and are not
       specified by POSIX.1.

So no parameter version of setpgrp was shortly specified and then obsoleted, and the 2 argument version (which this thread is about) never was standarized
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 13, 2022, 11:29:49 pm
So no parameter version of setpgrp was shortly specified and then obsoleted, and the 2 argument version (which this thread is about) never was standarized

I don't think OP specifies the number of parameters. In any event, there appear to be Linux syscalls that can't be easily accessed other than by going via the termios stuff (which, TBH, is probably functionally adequate).

MarkMLl
Title: Re: equivalent setpgrp() in lazarus
Post by: Thaddy on May 14, 2022, 02:29:46 pm
It looks as though the Netware RTL is the only one to implement FpSetpgid(), which might in practice be what OP's looking for.

MarkMLl
Yes. Correct. Grep will tell you so too... (I am repeating myself).
Now playing The Hyves again. https://www.youtube.com/watch?v=Uz1Jwyxd4tE Useful song..
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 14, 2022, 03:36:51 pm
Yes. Correct. Grep will tell you so too... (I am repeating myself).

Yes, I found it via grep. But what he /should/ be looking for is setpgid(), which is unimplemented.

MarkMLl
Title: Re: equivalent setpgrp() in lazarus
Post by: Thaddy on May 15, 2022, 12:46:16 am
[Yes, I found it via grep. But what he /should/ be looking for is setpgid(), which is unimplemented.

MarkMLl
That should be fpsetpgid()...
Title: Re: equivalent setpgrp() in lazarus
Post by: MarkMLl on May 15, 2022, 09:05:54 am
That should be fpsetpgid()...

Agreed, from the POV of FPC naming.

MarkMLl
TinyPortal © 2005-2018