Re: [fpc-pascal] The keyboard unit

2019-05-11 Thread Kevin Lyda
And looking a bit further, I see this has been kind of addressed in r39579:

https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision=39579

The fix is imperfect - a process could have a ') ' in it, but it would
be unlikely. postfix and postgres appear to put a closing parens in
their argv[0] but always at the end.

So now I'm curious if a) working off fpc trunk is currently an OK idea
and b) if there are some good docs on doing that?

Kevin

On Sat, May 11, 2019 at 9:46 AM Kevin Lyda  wrote:
>
> Ralf, thanks! That was the idea, a small easy to test program.
>
> [NOTE: this email was a log of me debugging. If you want to skip to
> the issue: it's because the keyboard unit dies when running under tmux
> because /proc/PID/stat is harder to parse than the keyboard unit code
> assumes.]
>
> My setup is similar but slightly different: Ubuntu 18.04 and just
> using a Makefile and the commandline compiler. Am I missing a flag?
> When I run these:
>
> strace -o argh ./test
> strace -o argh ./test-without-keyboard
>
> diff -u argh*
> --- argh2019-05-11 08:24:54.015836828 +0100
> +++ argh2   2019-05-11 08:25:21.377836828 +0100
> @@ -9,26 +9,6 @@
>  ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
>  ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
>  readlink("/proc/self/exe", "/home/kevin/src/sandbox/older/fp"..., 255) = 45
> -getpid()= 2158
> -mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
> -1, 0) = 0x7bcbfb894000
> -open("/proc/2158/stat", O_RDONLY|O_LARGEFILE) = 3
> -read(3, "2158 (test) R 2156 2156 14867 34"..., 256) = 256
> -close(3)= 0
> -open("/proc/2156/stat", O_RDONLY|O_LARGEFILE) = 3
> -read(3, "2156 (strace) S 14867 2156 14867"..., 256) = 256
> -close(3)= 0
> -mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
> -1, 0) = 0x7bcbfb88c000
> -open("/proc/14867/stat", O_RDONLY|O_LARGEFILE) = 3
> -read(3, "14867 (zsh) S 522 14867 14867 34"..., 256) = 256
> -close(3)= 0
> -open("/proc/522/stat", O_RDONLY|O_LARGEFILE) = 3
> -read(3, "522 (tmux: server) S 131 522 522"..., 256) = 256
> -write(2, "Runtime error 106 at $00"..., 39) = 39
> -write(2, "  $0042968D\n", 20)   = 20
> -ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
> -write(2, "  $0040018C\n", 20)   = 20
> -write(2, "\n", 1)   = 1
> -munmap(0x7bcbfb88c000, 32768)   = 0
> -munmap(0x7bcbfb894000, 32768)   = 0
> -exit_group(106) = ?
> -+++ exited with 106 +++
> +write(1, "Hello World.\n", 13)  = 13
> +exit_group(0)   = ?
>  exited with 0 +++
>
> OK, so it seems to read through the ancestors of its process and dies
> when it reads the /proc/PID/stat of the tmux process. So, what if I
> run it without tmux: strace -o argh3 ./test which runs fine and exits
> cleanly. So what's the difference? diff -u argh{,3}
>
> --- argh2019-05-11 08:24:54.015836828 +0100
> +++ argh3   2019-05-11 08:40:16.456836828 +0100
> @@ -9,26 +9,31 @@
>  ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
>  ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
>  readlink("/proc/self/exe", "/home/kevin/src/sandbox/older/fp"..., 255) = 45
> -getpid()= 2158
> -mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
> -1, 0) = 0x7bcbfb894000
> -open("/proc/2158/stat", O_RDONLY|O_LARGEFILE) = 3
> -read(3, "2158 (test) R 2156 2156 14867 34"..., 256) = 256
> -close(3)= 0
> -open("/proc/2156/stat", O_RDONLY|O_LARGEFILE) = 3
> -read(3, "2156 (strace) S 14867 2156 14867"..., 256) = 256
> -close(3)= 0
> -mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
> -1, 0) = 0x7bcbfb88c000
> -open("/proc/14867/stat", O_RDONLY|O_LARGEFILE) = 3
> -read(3, "14867 (zsh) S 522 14867 14867 34"..., 256) = 256
> -close(3)= 0
> -open("/proc/522/stat", O_RDONLY|O_LARGEFILE) = 3
> -read(3, "522 (tmux: server) S 131 522 522"..., 256) = 256
> -write(2, "Runtime error 106 at $00"..., 39) = 39
> -write(2, "  $0042968D\n", 20)   = 20
> -ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
> -write(2, "  $0040018C\n", 20)   = 20
> -write(2, "\n", 1)   = 1
> -munmap(0x7bcbfb88c000, 32768)   = 0
> -munmap(0x7bcbfb894000, 32768)   = 0
> -exit_group(106) = ?
> -+++ exited with 106 +++
> +getpid()= 2719
> +mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
> -1, 0) = 0x7f8092c23000
> +open("/proc/2719/stat", O_RDONLY|O_LARGEFILE) = 3
> +read(3, "2719 (test) R 2717 2717 2429 348"..., 256) = 256
> +close(3)= 0
> +open("/proc/2717/stat", O_RDONLY|O_LARGEFILE) = 3
> 

Re: [fpc-pascal] The keyboard unit

2019-05-11 Thread Kevin Lyda
Ralf, thanks! That was the idea, a small easy to test program.

[NOTE: this email was a log of me debugging. If you want to skip to
the issue: it's because the keyboard unit dies when running under tmux
because /proc/PID/stat is harder to parse than the keyboard unit code
assumes.]

My setup is similar but slightly different: Ubuntu 18.04 and just
using a Makefile and the commandline compiler. Am I missing a flag?
When I run these:

strace -o argh ./test
strace -o argh ./test-without-keyboard

diff -u argh*
--- argh2019-05-11 08:24:54.015836828 +0100
+++ argh2   2019-05-11 08:25:21.377836828 +0100
@@ -9,26 +9,6 @@
 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
 ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
 readlink("/proc/self/exe", "/home/kevin/src/sandbox/older/fp"..., 255) = 45
-getpid()= 2158
-mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7bcbfb894000
-open("/proc/2158/stat", O_RDONLY|O_LARGEFILE) = 3
-read(3, "2158 (test) R 2156 2156 14867 34"..., 256) = 256
-close(3)= 0
-open("/proc/2156/stat", O_RDONLY|O_LARGEFILE) = 3
-read(3, "2156 (strace) S 14867 2156 14867"..., 256) = 256
-close(3)= 0
-mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7bcbfb88c000
-open("/proc/14867/stat", O_RDONLY|O_LARGEFILE) = 3
-read(3, "14867 (zsh) S 522 14867 14867 34"..., 256) = 256
-close(3)= 0
-open("/proc/522/stat", O_RDONLY|O_LARGEFILE) = 3
-read(3, "522 (tmux: server) S 131 522 522"..., 256) = 256
-write(2, "Runtime error 106 at $00"..., 39) = 39
-write(2, "  $0042968D\n", 20)   = 20
-ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
-write(2, "  $0040018C\n", 20)   = 20
-write(2, "\n", 1)   = 1
-munmap(0x7bcbfb88c000, 32768)   = 0
-munmap(0x7bcbfb894000, 32768)   = 0
-exit_group(106) = ?
-+++ exited with 106 +++
+write(1, "Hello World.\n", 13)  = 13
+exit_group(0)   = ?
 exited with 0 +++

OK, so it seems to read through the ancestors of its process and dies
when it reads the /proc/PID/stat of the tmux process. So, what if I
run it without tmux: strace -o argh3 ./test which runs fine and exits
cleanly. So what's the difference? diff -u argh{,3}

--- argh2019-05-11 08:24:54.015836828 +0100
+++ argh3   2019-05-11 08:40:16.456836828 +0100
@@ -9,26 +9,31 @@
 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
 ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
 readlink("/proc/self/exe", "/home/kevin/src/sandbox/older/fp"..., 255) = 45
-getpid()= 2158
-mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7bcbfb894000
-open("/proc/2158/stat", O_RDONLY|O_LARGEFILE) = 3
-read(3, "2158 (test) R 2156 2156 14867 34"..., 256) = 256
-close(3)= 0
-open("/proc/2156/stat", O_RDONLY|O_LARGEFILE) = 3
-read(3, "2156 (strace) S 14867 2156 14867"..., 256) = 256
-close(3)= 0
-mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7bcbfb88c000
-open("/proc/14867/stat", O_RDONLY|O_LARGEFILE) = 3
-read(3, "14867 (zsh) S 522 14867 14867 34"..., 256) = 256
-close(3)= 0
-open("/proc/522/stat", O_RDONLY|O_LARGEFILE) = 3
-read(3, "522 (tmux: server) S 131 522 522"..., 256) = 256
-write(2, "Runtime error 106 at $00"..., 39) = 39
-write(2, "  $0042968D\n", 20)   = 20
-ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
-write(2, "  $0040018C\n", 20)   = 20
-write(2, "\n", 1)   = 1
-munmap(0x7bcbfb88c000, 32768)   = 0
-munmap(0x7bcbfb894000, 32768)   = 0
-exit_group(106) = ?
-+++ exited with 106 +++
+getpid()= 2719
+mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7f8092c23000
+open("/proc/2719/stat", O_RDONLY|O_LARGEFILE) = 3
+read(3, "2719 (test) R 2717 2717 2429 348"..., 256) = 256
+close(3)= 0
+open("/proc/2717/stat", O_RDONLY|O_LARGEFILE) = 3
+read(3, "2717 (strace) S 2429 2717 2429 3"..., 256) = 256
+close(3)= 0
+open("/proc/2429/stat", O_RDONLY|O_LARGEFILE) = 3
+read(3, "2429 (zsh) S 2427 2429 2429 3481"..., 256) = 256
+close(3)= 0
+open("/proc/2427/stat", O_RDONLY|O_LARGEFILE) = 3
+read(3, "2427 (ld-linux-x86-64) S 364 242"..., 256) = 256
+close(3)= 0
+open("/etc/timezone", O_RDONLY|O_LARGEFILE) = 3
+read(3, "Etc/UTC\n", 255)   = 8
+close(3)= 0
+open("/usr/share/zoneinfo/Etc/UTC", O_RDONLY|O_LARGEFILE) = 3
+read(3, 

Re: [fpc-pascal] The keyboard unit

2019-05-10 Thread Ralf Quint

On 5/10/2019 4:42 PM, Kevin Lyda wrote:

If I remove the uses clause it runs fine.  Why is the keyboard unit,
which isn't even being used, causing this error?

Kevin


Well, when I got home a short while ago, I tried that small test program 
on one of my Linux workstations and it runs just fine...


FPC 3.04 as installed with Lazarus 2.02 (ok, installed the 3 .deb 
packages for fpc, fpc-source and lazarus 2.02 from the lazarus 
SourceForge repo), compiled and running on Linux Mint 19.2/64, tried 
both Cinnamon and Mate, on two different hosts...


Ralf


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] The keyboard unit

2019-05-10 Thread Alexander Grotewohl
if it's not being used, remove it :)but really though, do any of the fleshed out examples on the website work? like the one from here?:https://www.freepascal.org/docs-html/rtl/keyboard/getkeyevent.html--Alexander Grotewohlhttp://dcclost.com___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] The keyboard unit

2019-05-10 Thread Ralf Quint

On 5/10/2019 4:42 PM, Kevin Lyda wrote:

When I compile and run this small test program (
https://gist.github.com/lyda/2d33a6d91067e9dffb4ed37147b52583 ) the
following happens:

% fpc test.pas
Free Pascal Compiler version 3.0.4+dfsg-22~bpo9+2 [2019/02/22] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test.pas
Linking test
/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
7 lines compiled, 0.1 sec

% ./test
Runtime error 106 at $0042968D
   $0042968D
   $0040018C

If I remove the uses clause it runs fine.  Why is the keyboard unit,
which isn't even being used, causing this error?

Kevin

Away from any computer with FreePascal installed, but could it be that 
this is a non-Linux aware unit which does something DOS-specific (as you 
select TP mode), which of course doesn't work under Linux...


Ralf


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] The keyboard unit

2019-05-10 Thread Kevin Lyda
When I compile and run this small test program (
https://gist.github.com/lyda/2d33a6d91067e9dffb4ed37147b52583 ) the
following happens:

% fpc test.pas
Free Pascal Compiler version 3.0.4+dfsg-22~bpo9+2 [2019/02/22] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test.pas
Linking test
/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
7 lines compiled, 0.1 sec

% ./test
Runtime error 106 at $0042968D
  $0042968D
  $0040018C

If I remove the uses clause it runs fine.  Why is the keyboard unit,
which isn't even being used, causing this error?

Kevin

-- 
Kevin Lyda
Galway, Ireland
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal